Use binary search in isCPUStringValid since the array is sorted.
authorCraig Topper <craig.topper@gmail.com>
Sat, 17 Oct 2015 16:37:09 +0000 (16:37 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 17 Oct 2015 16:37:09 +0000 (16:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250613 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCSubtargetInfo.h

index d5ad4eebf9ef9d6d9f7c0bfabb9d79d2580416a1..30dfa1999e618e8de9e9b856366ecb8596c99889 100644 (file)
@@ -159,11 +159,8 @@ public:
 
   /// Check whether the CPU string is valid.
   bool isCPUStringValid(StringRef CPU) const {
-    auto Found = std::find_if(ProcDesc.begin(), ProcDesc.end(),
-                              [=](const SubtargetFeatureKV &KV) {
-                                return CPU == KV.Key; 
-                              });
-    return Found != ProcDesc.end();
+    auto Found = std::lower_bound(ProcDesc.begin(), ProcDesc.end(), CPU);
+    return Found != ProcDesc.end() && StringRef(Found->Key) == CPU;
   }
 };