]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/cmdparse: do not create temp string for cmd_getval()
authorKefu Chai <kchai@redhat.com>
Mon, 7 Jun 2021 06:54:02 +0000 (14:54 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 7 Jun 2021 14:11:58 +0000 (22:11 +0800)
cmd_getval() consumes string_view, so no need to create a temporary
std::string instance for it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/cmdparse.cc

index d02a2b99bbd11913f485cb04e9d513ebe2977d76..90da6afef90deeea0b963d94078b8d9e5b72d6fd 100644 (file)
@@ -578,7 +578,7 @@ bool validate_bool(CephContext *cct,
 {
   bool v;
   try {
-    if (!cmd_getval(cmdmap, string(name), v)) {
+    if (!cmd_getval(cmdmap, name, v)) {
       if (auto req = desc.find("req");
          req != end(desc) && req->second == "false") {
        return true;
@@ -607,7 +607,7 @@ bool validate_arg(CephContext* cct,
 {
   Value v;
   try {
-    if (!cmd_getval(cmdmap, string(name), v)) {
+    if (!cmd_getval(cmdmap, name, v)) {
       if constexpr (is_vector) {
          // an empty list is acceptable.
          return true;