summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2016-01-03 07:33:45 +0000
committerCraig Topper <craig.topper@gmail.com>2016-01-03 07:33:45 +0000
commit5f167729aa3a3ff55758ac94e725bccc7f81fb55 (patch)
treeb495d531231dc7da296b931b6463a55e0cf98b88 /llvm
parent1097df3b4ac0daf4f7dabb2fd4a8887280617e93 (diff)
downloadbcm5719-llvm-5f167729aa3a3ff55758ac94e725bccc7f81fb55.tar.gz
bcm5719-llvm-5f167729aa3a3ff55758ac94e725bccc7f81fb55.zip
Use std::is_sorted instead of manual loops. NFC
llvm-svn: 256701
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/SubtargetFeature.h5
-rw-r--r--llvm/lib/MC/SubtargetFeature.cpp12
2 files changed, 9 insertions, 8 deletions
diff --git a/llvm/include/llvm/MC/SubtargetFeature.h b/llvm/include/llvm/MC/SubtargetFeature.h
index 02c9e82ad3a..40d4739fe9c 100644
--- a/llvm/include/llvm/MC/SubtargetFeature.h
+++ b/llvm/include/llvm/MC/SubtargetFeature.h
@@ -59,6 +59,11 @@ struct SubtargetFeatureKV {
bool operator<(StringRef S) const {
return StringRef(Key) < S;
}
+
+ // Compare routine for std::is_sorted.
+ bool operator<(const SubtargetFeatureKV &Other) const {
+ return StringRef(Key) < StringRef(Other.Key);
+ }
};
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp
index b642f17f0e7..c1f5fc95cf5 100644
--- a/llvm/lib/MC/SubtargetFeature.cpp
+++ b/llvm/lib/MC/SubtargetFeature.cpp
@@ -234,14 +234,10 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
return FeatureBitset();
#ifndef NDEBUG
- for (size_t i = 1, e = CPUTable.size(); i != e; ++i) {
- assert(strcmp(CPUTable[i - 1].Key, CPUTable[i].Key) < 0 &&
- "CPU table is not sorted");
- }
- for (size_t i = 1, e = FeatureTable.size(); i != e; ++i) {
- assert(strcmp(FeatureTable[i - 1].Key, FeatureTable[i].Key) < 0 &&
- "CPU features table is not sorted");
- }
+ assert(std::is_sorted(std::begin(CPUTable), std::end(CPUTable)) &&
+ "CPU table is not sorted");
+ assert(std::is_sorted(std::begin(FeatureTable), std::end(FeatureTable)) &&
+ "CPU features table is not sorted");
#endif
// Resulting bits
FeatureBitset Bits;
OpenPOWER on IntegriCloud