[llvm] r250613 - Use binary search in isCPUStringValid since the array is sorted.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 17 09:37:09 PDT 2015
Author: ctopper
Date: Sat Oct 17 11:37:09 2015
New Revision: 250613
URL: http://llvm.org/viewvc/llvm-project?rev=250613&view=rev
Log:
Use binary search in isCPUStringValid since the array is sorted.
Modified:
llvm/trunk/include/llvm/MC/MCSubtargetInfo.h
Modified: llvm/trunk/include/llvm/MC/MCSubtargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSubtargetInfo.h?rev=250613&r1=250612&r2=250613&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSubtargetInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCSubtargetInfo.h Sat Oct 17 11:37:09 2015
@@ -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;
}
};
More information about the llvm-commits
mailing list