]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/ActivePyModule: return std::string_view instead of std::string copy
authorMax Kellermann <max.kellermann@ionos.com>
Thu, 10 Oct 2024 06:19:20 +0000 (08:19 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Thu, 10 Oct 2024 06:54:12 +0000 (08:54 +0200)
This impliciy heap allocation is unnecessary.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mgr/ActivePyModule.h
src/mgr/ActivePyModules.cc

index 187fb68f846eba1fca71f1f17e4f33a5b9f38fd1..fb4a43e2de7c479537b4933a243066d004526e49 100644 (file)
@@ -97,12 +97,12 @@ public:
     uri = str;
   }
 
-  std::string get_uri() const
+  std::string_view get_uri() const
   {
     return uri;
   }
 
-  std::string get_fin_thread_name() const
+  std::string_view get_fin_thread_name() const
   {
     return fin_thread_name;
   }
index 17bb3951142abe2dad0bf1547d1b2edda378af3e..aebbb5d8c9a2a362424c01e6ff20d0a45a73a809 100644 (file)
@@ -770,9 +770,9 @@ std::map<std::string, std::string> ActivePyModules::get_services() const
   std::map<std::string, std::string> result;
   std::lock_guard l(lock);
   for (const auto& [name, module] : modules) {
-    std::string svc_str = module->get_uri();
+    const std::string_view svc_str = module->get_uri();
     if (!svc_str.empty()) {
-      result[name] = svc_str;
+      result.emplace(name, svc_str);
     }
   }