summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-10-22 18:32:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-10-22 18:32:06 +0000
commitfc063e8fec64b72ef06a5e4ec8835745e6548740 (patch)
tree665727f29a1b2bf89db79ade949f210512ed76f0 /llvm/include
parentd276de6db1c231f5338cb05847654fcd21a8317a (diff)
downloadbcm5719-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.h16
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();
OpenPOWER on IntegriCloud