From: Kefu Chai Date: Wed, 21 Apr 2021 13:47:29 +0000 (+0800) Subject: mgr/PyModuleRegistry: use vector<> when appropriate X-Git-Tag: v17.1.0~2178^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7d2964bf782eb3f4d39cca2c2098501caf8a8de3;p=ceph.git mgr/PyModuleRegistry: use vector<> when appropriate no need to use a set for storing module name, they are inherently unique. Signed-off-by: Kefu Chai --- diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index 1ae44143c7d8..79c42653620d 100644 --- a/src/mgr/PyModuleRegistry.cc +++ b/src/mgr/PyModuleRegistry.cc @@ -75,7 +75,7 @@ void PyModuleRegistry::init() std::list failed_modules; const std::string module_path = g_conf().get_val("mgr_module_path"); - std::set 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 PyModuleRegistry::probe_modules(const std::string &path) const +std::vector PyModuleRegistry::probe_modules(const std::string &path) const { const auto opt = g_conf().get_val("mgr_disabled_modules"); const auto disabled_modules = ceph::split(opt); - std::set modules; + std::vector modules; for (const auto& entry: fs::directory_iterator(path)) { if (!fs::is_directory(entry)) { continue; @@ -287,7 +287,7 @@ std::set 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; diff --git a/src/mgr/PyModuleRegistry.h b/src/mgr/PyModuleRegistry.h index ad48af9dafea..27590107bb7c 100644 --- a/src/mgr/PyModuleRegistry.h +++ b/src/mgr/PyModuleRegistry.h @@ -58,7 +58,7 @@ private: /** * Discover python modules from local disk */ - std::set probe_modules(const std::string &path) const; + std::vector probe_modules(const std::string &path) const; PyModuleConfig module_config;