From: Max Kellermann Date: Thu, 10 Oct 2024 06:19:20 +0000 (+0200) Subject: mgr/ActivePyModule: return std::string_view instead of std::string copy X-Git-Tag: testing/wip-pdonnell-testing-20241019.005706-debug~1^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9d47b164afde3529d43f142356980e3d9853e07f;p=ceph-ci.git mgr/ActivePyModule: return std::string_view instead of std::string copy This impliciy heap allocation is unnecessary. Signed-off-by: Max Kellermann --- diff --git a/src/mgr/ActivePyModule.h b/src/mgr/ActivePyModule.h index 187fb68f846..fb4a43e2de7 100644 --- a/src/mgr/ActivePyModule.h +++ b/src/mgr/ActivePyModule.h @@ -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; } diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 17bb3951142..aebbb5d8c9a 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -770,9 +770,9 @@ std::map ActivePyModules::get_services() const std::map 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); } }