From 462ea55095d0fafb2db052142de773ed2cf14c05 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 26 Oct 2022 09:31:35 -0700 Subject: [PATCH] subcontext: Change a std::string argument into std::string_view This change prevents that a later CL will trigger the following warning: parameter 'test_context' is passed by value and only copied once; consider moving it to avoid unnecessary copies Change-Id: If5837ee6438efdf194781de041779c1089897789 Signed-off-by: Bart Van Assche --- init/subcontext.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init/subcontext.h b/init/subcontext.h index 8acc032d6..93ebacea2 100644 --- a/init/subcontext.h +++ b/init/subcontext.h @@ -36,8 +36,10 @@ static constexpr const char kTestContext[] = "test-test-test"; class Subcontext { public: - Subcontext(std::vector path_prefixes, std::string context, bool host = false) - : path_prefixes_(std::move(path_prefixes)), context_(std::move(context)), pid_(0) { + Subcontext(std::vector path_prefixes, std::string_view context, bool host = false) + : path_prefixes_(std::move(path_prefixes)), + context_(context.begin(), context.end()), + pid_(0) { if (!host) { Fork(); }