Skip to content

Commit 9d47b16

Browse files
committed
mgr/ActivePyModule: return std::string_view instead of std::string copy
This impliciy heap allocation is unnecessary. Signed-off-by: Max Kellermann <[email protected]>
1 parent 12e0c26 commit 9d47b16

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/mgr/ActivePyModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ class ActivePyModule : public PyModuleRunner
9797
uri = str;
9898
}
9999

100-
std::string get_uri() const
100+
std::string_view get_uri() const
101101
{
102102
return uri;
103103
}
104104

105-
std::string get_fin_thread_name() const
105+
std::string_view get_fin_thread_name() const
106106
{
107107
return fin_thread_name;
108108
}

src/mgr/ActivePyModules.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,9 @@ std::map<std::string, std::string> ActivePyModules::get_services() const
770770
std::map<std::string, std::string> result;
771771
std::lock_guard l(lock);
772772
for (const auto& [name, module] : modules) {
773-
std::string svc_str = module->get_uri();
773+
const std::string_view svc_str = module->get_uri();
774774
if (!svc_str.empty()) {
775-
result[name] = svc_str;
775+
result.emplace(name, svc_str);
776776
}
777777
}
778778

0 commit comments

Comments
 (0)