]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/PyModuleRegistry: use vector<> when appropriate
authorKefu Chai <kchai@redhat.com>
Wed, 21 Apr 2021 13:47:29 +0000 (21:47 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 21 Apr 2021 13:51:55 +0000 (21:51 +0800)
no need to use a set<string> for storing module name, they are
inherently unique.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/PyModuleRegistry.cc
src/mgr/PyModuleRegistry.h

index 1ae44143c7d80f36a5cf2e252fb98a0d672380c4..79c42653620d749392f001f5f15e2a2135555402 100644 (file)
@@ -75,7 +75,7 @@ void PyModuleRegistry::init()
   std::list<std::string> failed_modules;
 
   const std::string module_path = g_conf().get_val<std::string>("mgr_module_path");
-  std::set<std::string> module_names = probe_modules(module_path);
+  auto module_names = probe_modules(module_path);
   // Load python code
   for (const auto& module_name : module_names) {
     dout(1) << "Loading python module '" << module_name << "'" << dendl;
@@ -270,12 +270,12 @@ void PyModuleRegistry::shutdown()
   Py_Finalize();
 }
 
-std::set<std::string> PyModuleRegistry::probe_modules(const std::string &path) const
+std::vector<std::string> PyModuleRegistry::probe_modules(const std::string &path) const
 {
   const auto opt = g_conf().get_val<std::string>("mgr_disabled_modules");
   const auto disabled_modules = ceph::split(opt);
 
-  std::set<std::string> modules;
+  std::vector<std::string> modules;
   for (const auto& entry: fs::directory_iterator(path)) {
     if (!fs::is_directory(entry)) {
       continue;
@@ -287,7 +287,7 @@ std::set<std::string> PyModuleRegistry::probe_modules(const std::string &path) c
     }
     auto module_path = entry.path() / "module.py";
     if (fs::exists(module_path)) {
-      modules.emplace(name);
+      modules.push_back(name);
     }
   }
   return modules;
index ad48af9dafea64d5df4ecc530b48b9754b7e5e5e..27590107bb7cac9406ae68a6c777d80660228b0b 100644 (file)
@@ -58,7 +58,7 @@ private:
   /**
    * Discover python modules from local disk
    */
-  std::set<std::string> probe_modules(const std::string &path) const;
+  std::vector<std::string> probe_modules(const std::string &path) const;
 
   PyModuleConfig module_config;