From: Craig Topper Date: Sun, 3 Jan 2016 08:45:36 +0000 (+0000) Subject: Use an ArrayRef to simplify repeated calculation of the array end. NFC X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2e085133b37d1312d26e7ca8d5a0e81732654695;p=oota-llvm.git Use an ArrayRef to simplify repeated calculation of the array end. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256702 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCSubtargetInfo.cpp b/lib/MC/MCSubtargetInfo.cpp index dc864d3a17f..b29d3f48310 100644 --- a/lib/MC/MCSubtargetInfo.cpp +++ b/lib/MC/MCSubtargetInfo.cpp @@ -77,17 +77,18 @@ FeatureBitset MCSubtargetInfo::ApplyFeatureFlag(StringRef FS) { 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 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"