Use binary search in isCPUStringValid since the array is sorted.
[oota-llvm.git] / 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;
   }
 };