]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rest: use ceph::split() for rgw_enable_apis
authorCasey Bodley <cbodley@redhat.com>
Thu, 3 Jul 2025 00:23:54 +0000 (20:23 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 20 May 2026 14:20:22 +0000 (10:20 -0400)
avoid allocating a list of strings to parse the comma-separated
rgw_enable_apis configuration

the range returned by ceph::split() has no size() function, so change
the calculation to not require it - `size() - distance(begin(), pos)`
is the same thing as `distance(pos, end())`

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rest.cc

index bf6534549276aa36b256b5d893c998f15931775f..cbc5126fd332a080e80be702ae98e9c05d30846a 100644 (file)
@@ -10,6 +10,7 @@
 #include "ceph_ver.h"
 #include "common/HTMLFormatter.h"
 #include "common/XMLFormatter.h"
+#include "common/split.h"
 #include "common/utf8.h"
 #include "include/str_list.h"
 #include "rgw_common.h"
@@ -2018,17 +2019,16 @@ int RGWREST::preprocess(req_state *s, rgw::io::BasicClient* cio)
   // S3 API.
   // Map the listing of rgw_enable_apis in REVERSE order, so that items near
   // the front of the list have a higher number assigned (and -1 for items not in the list).
-  list<string> apis;
-  get_str_list(g_conf()->rgw_enable_apis, apis);
+  const auto apis = ceph::split(g_conf()->rgw_enable_apis);
   int api_priority_s3 = -1;
   int api_priority_s3website = -1;
   auto api_s3website_priority_rawpos = std::find(apis.begin(), apis.end(), "s3website");
   auto api_s3_priority_rawpos = std::find(apis.begin(), apis.end(), "s3");
   if (api_s3_priority_rawpos != apis.end()) {
-    api_priority_s3 = apis.size() - std::distance(apis.begin(), api_s3_priority_rawpos);
+    api_priority_s3 = std::distance(api_s3_priority_rawpos, apis.end());
   }
   if (api_s3website_priority_rawpos != apis.end()) {
-    api_priority_s3website = apis.size() - std::distance(apis.begin(), api_s3website_priority_rawpos);
+    api_priority_s3website = std::distance(api_s3website_priority_rawpos, apis.end());
   }
   ldpp_dout(s, 10) << "rgw api priority: s3=" << api_priority_s3 << " s3website=" << api_priority_s3website << dendl;
   bool s3website_enabled = api_priority_s3website >= 0;