diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-10-22 18:32:06 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-10-22 18:32:06 +0000 |
| commit | fc063e8fec64b72ef06a5e4ec8835745e6548740 (patch) | |
| tree | 665727f29a1b2bf89db79ade949f210512ed76f0 /llvm/include | |
| parent | d276de6db1c231f5338cb05847654fcd21a8317a (diff) | |
| download | bcm5719-llvm-fc063e8fec64b72ef06a5e4ec8835745e6548740.tar.gz bcm5719-llvm-fc063e8fec64b72ef06a5e4ec8835745e6548740.zip | |
Avoid storing a second copy of each string in StringTableBuilder.
This was only use in the extremely uncommon case of @@@ symbols on ELF.
llvm-svn: 251039
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/MC/StringTableBuilder.h | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/include/llvm/MC/StringTableBuilder.h b/llvm/include/llvm/MC/StringTableBuilder.h index f38247702eb..414c3adc5ea 100644 --- a/llvm/include/llvm/MC/StringTableBuilder.h +++ b/llvm/include/llvm/MC/StringTableBuilder.h @@ -11,7 +11,7 @@ #define LLVM_MC_STRINGTABLEBUILDER_H #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/DenseMap.h" #include <cassert> namespace llvm { @@ -19,15 +19,12 @@ namespace llvm { /// \brief Utility for building string tables with deduplicated suffixes. class StringTableBuilder { SmallString<256> StringTable; - StringMap<size_t> StringIndexMap; + DenseMap<StringRef, size_t> StringIndexMap; public: /// \brief Add a string to the builder. Returns a StringRef to the internal /// copy of s. Can only be used before the table is finalized. - StringRef add(StringRef s) { - assert(!isFinalized()); - return StringIndexMap.insert(std::make_pair(s, 0)).first->first(); - } + void add(StringRef s); enum Kind { ELF, @@ -48,12 +45,7 @@ public: /// \brief Get the offest of a string in the string table. Can only be used /// after the table is finalized. - size_t getOffset(StringRef s) const { - assert(isFinalized()); - auto I = StringIndexMap.find(s); - assert(I != StringIndexMap.end() && "String is not in table!"); - return I->second; - } + size_t getOffset(StringRef s) const; void clear(); |

