[llvm] r251023 - Use array_pod_sort. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 08:15:44 PDT 2015
Author: rafael
Date: Thu Oct 22 10:15:44 2015
New Revision: 251023
URL: http://llvm.org/viewvc/llvm-project?rev=251023&view=rev
Log:
Use array_pod_sort. NFC.
Modified:
llvm/trunk/lib/MC/StringTableBuilder.cpp
Modified: llvm/trunk/lib/MC/StringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/StringTableBuilder.cpp?rev=251023&r1=251022&r2=251023&view=diff
==============================================================================
--- llvm/trunk/lib/MC/StringTableBuilder.cpp (original)
+++ llvm/trunk/lib/MC/StringTableBuilder.cpp Thu Oct 22 10:15:44 2015
@@ -9,12 +9,15 @@
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/COFF.h"
#include "llvm/Support/Endian.h"
using namespace llvm;
-static bool compareBySuffix(StringRef a, StringRef b) {
+static int compareBySuffix(const StringRef *AP, const StringRef *BP) {
+ StringRef a = *AP;
+ StringRef b = *BP;
size_t sizeA = a.size();
size_t sizeB = b.size();
size_t len = std::min(sizeA, sizeB);
@@ -22,9 +25,9 @@ static bool compareBySuffix(StringRef a,
char ca = a[sizeA - i - 1];
char cb = b[sizeB - i - 1];
if (ca != cb)
- return ca > cb;
+ return cb - ca;
}
- return sizeA > sizeB;
+ return sizeB - sizeA;
}
void StringTableBuilder::finalize(Kind kind) {
@@ -34,7 +37,7 @@ void StringTableBuilder::finalize(Kind k
for (auto i = StringIndexMap.begin(), e = StringIndexMap.end(); i != e; ++i)
Strings.push_back(i->getKey());
- std::sort(Strings.begin(), Strings.end(), compareBySuffix);
+ array_pod_sort(Strings.begin(), Strings.end(), compareBySuffix);
switch (kind) {
case ELF:
More information about the llvm-commits
mailing list