From: Casey Bodley Date: Thu, 14 Mar 2024 15:27:55 +0000 (-0400) Subject: rgw/pubsub: avoid allocating hash set of strings for attr search X-Git-Tag: testing/wip-yuriw-testing-20240416.150233~10^2~17 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1054929468d4caf2d3cf399959d9d18cbd759a50;p=ceph-ci.git 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) --- diff --git a/src/rgw/rgw_rest_pubsub.cc b/src/rgw/rgw_rest_pubsub.cc index 7914f813a20..d4204d686e2 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; }