[llvm] r290999 - YAML: Remove Input::MapHNode::isValidKey(), use llvm::is_contained() instead. NFC.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 12:10:43 PST 2017


Author: pcc
Date: Wed Jan  4 14:10:43 2017
New Revision: 290999

URL: http://llvm.org/viewvc/llvm-project?rev=290999&view=rev
Log:
YAML: Remove Input::MapHNode::isValidKey(), use llvm::is_contained() instead. NFC.

Modified:
    llvm/trunk/include/llvm/Support/YAMLTraits.h
    llvm/trunk/lib/Support/YAMLTraits.cpp

Modified: llvm/trunk/include/llvm/Support/YAMLTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLTraits.h?rev=290999&r1=290998&r2=290999&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLTraits.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLTraits.h Wed Jan  4 14:10:43 2017
@@ -1198,8 +1198,6 @@ private:
 
     typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode;
 
-    bool isValidKey(StringRef key);
-
     NameToNode                        Mapping;
     llvm::SmallVector<std::string, 6> ValidKeys;
   };

Modified: llvm/trunk/lib/Support/YAMLTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLTraits.cpp?rev=290999&r1=290998&r2=290999&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLTraits.cpp (original)
+++ llvm/trunk/lib/Support/YAMLTraits.cpp Wed Jan  4 14:10:43 2017
@@ -175,7 +175,7 @@ void Input::endMapping() {
   if (!MN)
     return;
   for (const auto &NN : MN->Mapping) {
-    if (!MN->isValidKey(NN.first())) {
+    if (!is_contained(MN->ValidKeys, NN.first())) {
       setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
       break;
     }
@@ -385,14 +385,6 @@ std::unique_ptr<Input::HNode> Input::cre
   }
 }
 
-bool Input::MapHNode::isValidKey(StringRef Key) {
-  for (std::string &K : ValidKeys) {
-    if (Key == K)
-      return true;
-  }
-  return false;
-}
-
 void Input::setError(const Twine &Message) {
   this->setError(CurrentNode, Message);
 }




More information about the llvm-commits mailing list