]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/options: dedup Option::services 41003/head
authorKefu Chai <kchai@redhat.com>
Fri, 23 Apr 2021 11:16:37 +0000 (19:16 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 14 May 2021 11:18:50 +0000 (19:18 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/options/build_options.cc

index ec3a1f9ecda8932f9d8537497c377984a2389f77..323548d16fabced1e073453fd5008afc7f3407df 100644 (file)
@@ -3,6 +3,9 @@
 
 #include "build_options.h"
 
+#include <algorithm>
+#include <cstring>
+
 std::vector<Option> get_global_options();
 std::vector<Option> get_mgr_options();
 std::vector<Option> get_crimson_options();
@@ -21,7 +24,12 @@ std::vector<Option> build_options()
 
   auto ingest = [&result](std::vector<Option>&& options, const char* svc) {
     for (auto &o : options) {
-      o.add_service(svc);
+      if (std::none_of(o.services.begin(), o.services.end(),
+                       [svc](const char* known_svc) {
+                         return std::strcmp(known_svc, svc) == 0;
+                       })) {
+        o.add_service(svc);
+      }
       result.push_back(std::move(o));
     }
   };