From abca699b59168346bc6548abde351c569354401d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 7 Jun 2021 14:57:28 +0800 Subject: [PATCH] common/cmdparse: do not create temp string for writing ostream ostream is able to handle std::string_view, so no need to create temporary std::string instance for writing to a std::ostream Signed-off-by: Kefu Chai --- src/common/cmdparse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 90da6afef90de..1d72320ef51b7 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -92,7 +92,7 @@ std::string cmddesc_get_prenautilus_compat(const std::string &cmddesc) // Instruct legacy clients or mons to send --foo-bar string in place // of a 'true'/'false' value std::ostringstream oss; - oss << std::string("--") << desckv["name"]; + oss << "--" << desckv["name"]; std::string val = oss.str(); std::replace(val.begin(), val.end(), '_', '-'); desckv["type"] = "CephChoices"; @@ -165,7 +165,7 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd) // Instruct legacy clients to send --foo-bar string in place // of a 'true'/'false' value std::ostringstream oss; - oss << std::string("--") << desckv["name"]; + oss << "--" << desckv["name"]; val = oss.str(); std::replace(val.begin(), val.end(), '_', '-'); -- 2.39.5