From: Changcheng Liu Date: Mon, 10 Aug 2020 01:48:46 +0000 (+0800) Subject: common/Formatter: don't construct string if string_view work X-Git-Tag: v16.1.0~1383^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=18da7d77f71a3021776e54bbbd101c04548fec9b;p=ceph.git common/Formatter: don't construct string if string_view work Signed-off-by: Changcheng Liu --- diff --git a/src/common/Formatter.cc b/src/common/Formatter.cc index 5d268aab7427..840857d94e56 100644 --- a/src/common/Formatter.cc +++ b/src/common/Formatter.cc @@ -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);