From: Piotr Dałek Date: Thu, 8 Feb 2018 15:17:56 +0000 (+0100) Subject: common/ConfUtils: check key before actually normalizing X-Git-Tag: v13.0.2~253^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=989abb0b4c4bf761c39ac281ab3dd8e56b5b9fef;p=ceph.git common/ConfUtils: check key before actually normalizing 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 --- diff --git a/src/common/ConfUtils.cc b/src/common/ConfUtils.cc index db957760bf9a..c40cdce61bfa 100644 --- a/src/common/ConfUtils.cc +++ b/src/common/ConfUtils.cc @@ -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(), ' ', '_');