]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/pubsub: avoid allocating hash set of strings for attr search
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 Mar 2024 15:27:55 +0000 (11:27 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:30 +0000 (15:34 -0400)
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 <cbodley@redhat.com>
(cherry picked from commit 70fc1eae8f5492dd30a650d25c3fe03c29a60426)

src/rgw/rgw_rest_pubsub.cc

index 7914f813a209d4f79a7c8dcba438ed4cb4e3cb4d..d4204d686e247a604a333737f68a39b64b83f5b8 100644 (file)
@@ -734,10 +734,10 @@ class RGWPSSetTopicAttributesOp : public RGWOp {
                                                : end_pos;
         push_endpoint_args.replace(pos, end_pos - pos, replaced_str);
       };
-      const std::unordered_set<std::string> push_endpoint_args = {
+      static constexpr std::initializer_list<const char*> 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;
       }