]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ConfUtils: check key before actually normalizing 20370/head
authorPiotr Dałek <piotr.dalek@corp.ovh.com>
Thu, 8 Feb 2018 15:17:56 +0000 (16:17 +0100)
committerPiotr Dałek <piotr.dalek@corp.ovh.com>
Fri, 9 Feb 2018 07:57:19 +0000 (08:57 +0100)
Key normalization involves some copying and strlens, and these are
expensive.
Check if key contain whitespaces, normalize it only when it does.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
src/common/ConfUtils.cc

index db957760bf9a704ca4c6b4b634089966374f8fd3..c40cdce61bfa871ec8d5b4e05143ff0dbdbb6787 100644 (file)
@@ -252,6 +252,10 @@ trim_whitespace(std::string &str, bool strip_internal)
 std::string ConfFile::
 normalize_key_name(const std::string &key)
 {
+  if (key.find_first_of(" \t\r\n\f\v\xa0") == string::npos) {
+    return key;
+  }
+
   string k(key);
   ConfFile::trim_whitespace(k, true);
   std::replace(k.begin(), k.end(), ' ', '_');