From 1054929468d4caf2d3cf399959d9d18cbd759a50 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 14 Mar 2024 11:27:55 -0400 Subject: [PATCH] rgw/pubsub: avoid allocating hash set of strings for attr search this unordered_set was not static, so we reinitialized it on every call replace with a constexpr array of string_views so we can search through sequential memory that's laid out at compile time Signed-off-by: Casey Bodley (cherry picked from commit 70fc1eae8f5492dd30a650d25c3fe03c29a60426) --- src/rgw/rgw_rest_pubsub.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest_pubsub.cc b/src/rgw/rgw_rest_pubsub.cc index 7914f813a209d..d4204d686e247 100644 --- a/src/rgw/rgw_rest_pubsub.cc +++ b/src/rgw/rgw_rest_pubsub.cc @@ -734,10 +734,10 @@ class RGWPSSetTopicAttributesOp : public RGWOp { : end_pos; push_endpoint_args.replace(pos, end_pos - pos, replaced_str); }; - const std::unordered_set push_endpoint_args = { + static constexpr std::initializer_list args = { "verify-ssl", "use-ssl", "ca-location", "amqp-ack-level", "amqp-exchange", "kafka-ack-level", "mechanism", "cloudevents"}; - if (push_endpoint_args.count(attribute_name) == 1) { + if (std::find(args.begin(), args.end(), attribute_name) != args.end()) { replace_str(attribute_name, s->info.args.get("AttributeValue")); return 0; } -- 2.39.5