From: Max Kellermann Date: Wed, 9 Oct 2024 12:29:38 +0000 (+0200) Subject: common/Finisher: pass name as std::string_view to ctor X-Git-Tag: testing/wip-pdonnell-testing-20241019.005706-debug~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=efc96a2d134a6aa0cf420de79e1c33d2e3da2ac7;p=ceph-ci.git common/Finisher: pass name as std::string_view to ctor This eliminates a temporary `std::string`. Additionally, convert the `tn` parameter to an rvalue reference and move it to `thread_name`. Signed-off-by: Max Kellermann --- diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc index c6d3746d8c0..43550f35197 100644 --- a/src/common/Finisher.cc +++ b/src/common/Finisher.cc @@ -15,9 +15,9 @@ Finisher::Finisher(CephContext *cct_) : thread_name("fn_anonymous"), finisher_thread(this) {} -Finisher::Finisher(CephContext *cct_, std::string name, std::string tn) : +Finisher::Finisher(CephContext *cct_, std::string_view name, std::string &&tn) : cct(cct_), finisher_lock(ceph::make_mutex(fmt::format("Finisher::{}", name))), - thread_name(tn), + thread_name(std::move(tn)), finisher_thread(this) { PerfCountersBuilder b(cct, fmt::format("finisher-{}", name), l_finisher_first, l_finisher_last); diff --git a/src/common/Finisher.h b/src/common/Finisher.h index 1a89f4289b7..acee6594ca4 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -122,7 +122,7 @@ class Finisher { explicit Finisher(CephContext *cct_); /// Construct a named Finisher that logs its queue length. - Finisher(CephContext *cct_, std::string name, std::string tn); + Finisher(CephContext *cct_, std::string_view name, std::string &&tn); ~Finisher(); };