From: Kefu Chai Date: Mon, 7 Jun 2021 06:57:28 +0000 (+0800) Subject: common/cmdparse: do not create temp string for writing ostream X-Git-Tag: v17.1.0~1713^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=abca699b59168346bc6548abde351c569354401d;p=ceph.git 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 --- diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 90da6afef90d..1d72320ef51b 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(), '_', '-');