]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Formatter: don't construct string if string_view work 36534/head
authorChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 10 Aug 2020 01:48:46 +0000 (09:48 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Wed, 12 Aug 2020 01:14:45 +0000 (09:14 +0800)
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/common/Formatter.cc

index 5d268aab742753ae364201739cc20ce0438332e2..840857d94e5630aa39ba576b5436c9b6e590e418 100644 (file)
@@ -85,9 +85,10 @@ Formatter *Formatter::create(std::string_view type,
                             std::string_view default_type,
                             std::string_view fallback)
 {
-  std::string mytype(type);
-  if (mytype == "")
+  std::string_view mytype(type);
+  if (mytype.empty()) {
     mytype = default_type;
+  }
 
   if (mytype == "json")
     return new JSONFormatter(false);