[llvm] r256702 - Use an ArrayRef to simplify repeated calculation of the array end. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 3 00:45:37 PST 2016
Author: ctopper
Date: Sun Jan 3 02:45:36 2016
New Revision: 256702
URL: http://llvm.org/viewvc/llvm-project?rev=256702&view=rev
Log:
Use an ArrayRef to simplify repeated calculation of the array end. NFC
Modified:
llvm/trunk/lib/MC/MCSubtargetInfo.cpp
Modified: llvm/trunk/lib/MC/MCSubtargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSubtargetInfo.cpp?rev=256702&r1=256701&r2=256702&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSubtargetInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCSubtargetInfo.cpp Sun Jan 3 02:45:36 2016
@@ -77,17 +77,18 @@ FeatureBitset MCSubtargetInfo::ApplyFeat
const MCSchedModel &MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const {
assert(ProcSchedModels && "Processor machine model not available!");
- size_t NumProcs = ProcDesc.size();
- assert(std::is_sorted(ProcSchedModels, ProcSchedModels+NumProcs,
+ ArrayRef<SubtargetInfoKV> SchedModels(ProcSchedModels, ProcDesc.size());
+
+ assert(std::is_sorted(SchedModels.begin(), SchedModels.end(),
[](const SubtargetInfoKV &LHS, const SubtargetInfoKV &RHS) {
return strcmp(LHS.Key, RHS.Key) < 0;
}) &&
"Processor machine model table is not sorted");
// Find entry
- const SubtargetInfoKV *Found =
- std::lower_bound(ProcSchedModels, ProcSchedModels+NumProcs, CPU);
- if (Found == ProcSchedModels+NumProcs || StringRef(Found->Key) != CPU) {
+ auto Found =
+ std::lower_bound(SchedModels.begin(), SchedModels.end(), CPU);
+ if (Found == SchedModels.end() || StringRef(Found->Key) != CPU) {
if (CPU != "help") // Don't error if the user asked for help.
errs() << "'" << CPU
<< "' is not a recognized processor for this target"
More information about the llvm-commits
mailing list