Use std::is_sorted instead of manual loops. NFC
authorCraig Topper <craig.topper@gmail.com>
Sun, 3 Jan 2016 07:33:45 +0000 (07:33 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sun, 3 Jan 2016 07:33:45 +0000 (07:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256701 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/SubtargetFeature.h
lib/MC/SubtargetFeature.cpp

index 02c9e82ad3a618e427416c81a8a2d5e5350f8e28..40d4739fe9cba413472f68077dad9d8c23905637 100644 (file)
@@ -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);
+  }
 };
 
 //===----------------------------------------------------------------------===//
index b642f17f0e79bed47d96c8c39a0c59cb0df7bf2d..c1f5fc95cf57dda06b9f420dd0938b8e8c21ed78 100644 (file)
@@ -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;