15
15
16
16
using namespace llvm ;
17
17
18
- static int compareBySuffix (const StringRef *AP, const StringRef *BP) {
19
- StringRef a = *AP;
20
- StringRef b = *BP;
18
+ static int compareBySuffix (StringMapEntry<size_t > *const *AP,
19
+ StringMapEntry<size_t > *const *BP) {
20
+ StringRef a = (*AP)->first ();
21
+ StringRef b = (*BP)->first ();
21
22
size_t sizeA = a.size ();
22
23
size_t sizeB = b.size ();
23
24
size_t len = std::min (sizeA, sizeB);
@@ -31,11 +32,10 @@ static int compareBySuffix(const StringRef *AP, const StringRef *BP) {
31
32
}
32
33
33
34
void StringTableBuilder::finalize (Kind kind) {
34
- SmallVector<StringRef, 8 > Strings;
35
+ std::vector<StringMapEntry< size_t > * > Strings;
35
36
Strings.reserve (StringIndexMap.size ());
36
-
37
- for (auto i = StringIndexMap.begin (), e = StringIndexMap.end (); i != e; ++i)
38
- Strings.push_back (i->getKey ());
37
+ for (StringMapEntry<size_t > &P : StringIndexMap)
38
+ Strings.push_back (&P);
39
39
40
40
array_pod_sort (Strings.begin (), Strings.end (), compareBySuffix);
41
41
@@ -52,16 +52,17 @@ void StringTableBuilder::finalize(Kind kind) {
52
52
}
53
53
54
54
StringRef Previous;
55
- for (StringRef s : Strings) {
55
+ for (StringMapEntry<size_t > *P : Strings) {
56
+ StringRef s = P->first ();
56
57
if (kind == WinCOFF)
57
58
assert (s.size () > COFF::NameSize && " Short string in COFF string table!" );
58
59
59
60
if (Previous.endswith (s)) {
60
- StringIndexMap[s] = StringTable.size () - 1 - s.size ();
61
+ P-> second = StringTable.size () - 1 - s.size ();
61
62
continue ;
62
63
}
63
64
64
- StringIndexMap[s] = StringTable.size ();
65
+ P-> second = StringTable.size ();
65
66
StringTable += s;
66
67
StringTable += ' \x00 ' ;
67
68
Previous = s;
0 commit comments