]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/cmdparse: do not create temp string for writing ostream 41724/head
authorKefu Chai <kchai@redhat.com>
Mon, 7 Jun 2021 06:57:28 +0000 (14:57 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 7 Jun 2021 14:11:58 +0000 (22:11 +0800)
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 <kchai@redhat.com>
src/common/cmdparse.cc

index 90da6afef90deeea0b963d94078b8d9e5b72d6fd..1d72320ef51b7859ac6da71ae35a5e0e8d787967 100644 (file)
@@ -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(), '_', '-');