[PATCH] D19933: Make StringTableBuilder to cache hash values.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu May 5 17:57:58 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268698: Make StringTableBuilder to cache hash values. (authored by ruiu).
Changed prior to commit:
http://reviews.llvm.org/D19933?vs=56195&id=56374#toc
Repository:
rL LLVM
http://reviews.llvm.org/D19933
Files:
llvm/trunk/include/llvm/MC/StringTableBuilder.h
llvm/trunk/lib/MC/StringTableBuilder.cpp
Index: llvm/trunk/include/llvm/MC/StringTableBuilder.h
===================================================================
--- llvm/trunk/include/llvm/MC/StringTableBuilder.h
+++ llvm/trunk/include/llvm/MC/StringTableBuilder.h
@@ -23,7 +23,7 @@
private:
SmallString<256> StringTable;
- DenseMap<StringRef, size_t> StringIndexMap;
+ DenseMap<CachedHash<StringRef>, size_t> StringIndexMap;
size_t Size = 0;
Kind K;
unsigned Alignment;
@@ -57,7 +57,10 @@
/// after the table is finalized.
size_t getOffset(StringRef S) const;
- const DenseMap<StringRef, size_t> &getMap() const { return StringIndexMap; }
+ const DenseMap<CachedHash<StringRef>, size_t> &getMap() const {
+ return StringIndexMap;
+ }
+
size_t getSize() const { return Size; }
void clear();
Index: llvm/trunk/lib/MC/StringTableBuilder.cpp
===================================================================
--- llvm/trunk/lib/MC/StringTableBuilder.cpp
+++ llvm/trunk/lib/MC/StringTableBuilder.cpp
@@ -34,11 +34,11 @@
}
}
-typedef std::pair<StringRef, size_t> StringPair;
+typedef std::pair<CachedHash<StringRef>, size_t> StringPair;
// Returns the character at Pos from end of a string.
static int charTailAt(StringPair *P, size_t Pos) {
- StringRef S = P->first;
+ StringRef S = P->first.Val;
if (Pos >= S.size())
return -1;
return (unsigned char)S[S.size() - Pos - 1];
@@ -86,7 +86,7 @@
}
void StringTableBuilder::finalizeStringTable(bool Optimize) {
- typedef std::pair<StringRef, size_t> StringOffsetPair;
+ typedef std::pair<CachedHash<StringRef>, size_t> StringOffsetPair;
std::vector<StringOffsetPair *> Strings;
Strings.reserve(StringIndexMap.size());
for (StringOffsetPair &P : StringIndexMap)
@@ -121,7 +121,7 @@
StringRef Previous;
for (StringOffsetPair *P : Strings) {
- StringRef S = P->first;
+ StringRef S = P->first.Val;
if (K == WinCOFF)
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19933.56374.patch
Type: text/x-patch
Size: 1997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/0c832c93/attachment.bin>
More information about the llvm-commits
mailing list