]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: streamline get_val_generic
authorSage Weil <sage@redhat.com>
Mon, 20 Nov 2017 21:28:12 +0000 (15:28 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:10 +0000 (14:44 -0600)
Lookup value first; avoid a schema lookup entirely.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config.cc

index 6639ea12b6f5c2c7972bbf3fc36f84c5643fa7ac..c833433de2928fcd8b3111073fd2ed7e0b214562 100644 (file)
@@ -911,14 +911,12 @@ Option::value_t md_config_t::_get_val_generic(const std::string &key) const
   // In key names, leading and trailing whitespace are not significant.
   string k(ConfFile::normalize_key_name(key));
 
-  const auto &opt_iter = schema.find(k);
-  if (opt_iter != schema.end()) {
-    // Using .at() is safe because all keys in the schema always have
-    // entries in ::values
-    return values.at(k);
-  } else {
-    return Option::value_t(boost::blank());
+  auto p = values.find(k);
+  if (p != values.end()) {
+    return p->second;
   }
+
+  return Option::value_t(boost::blank());
 }
 
 int md_config_t::_get_val_as_string(const std::string &key,