]> granicus.if.org Git - llvm/commitdiff
Allow the caller to pass in the hash.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 5 Oct 2016 18:46:21 +0000 (18:46 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 5 Oct 2016 18:46:21 +0000 (18:46 +0000)
If the caller already has the hash we don't have to compute it. This
will be used in lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283359 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/StringTableBuilder.h
lib/MC/StringTableBuilder.cpp

index 90d1bc36f166a89e00ebedceff028b5b882fb133..e63a3530eecb8c7ee957a6fa4aca7f3ccd6c4992 100644 (file)
@@ -31,6 +31,7 @@ public:
   }
 
   StringRef val() const { return StringRef(P, Size); }
+  uint32_t size() const { return Size; }
   uint32_t hash() const { return Hash; }
 };
 
@@ -56,7 +57,8 @@ public:
   /// \brief Add a string to the builder. Returns the position of S in the
   /// table. The position will be changed if finalize is used.
   /// Can only be used before the table is finalized.
-  size_t add(StringRef S);
+  size_t add(CachedHashString S);
+  size_t add(StringRef S) { return add(CachedHashString(S)); }
 
   /// \brief Analyze the strings and build the final table. No more strings can
   /// be added after this point.
@@ -68,7 +70,8 @@ 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;
+  size_t getOffset(CachedHashString S) const;
+  size_t getOffset(StringRef S) const { return getOffset(CachedHashString(S)); }
 
   size_t getSize() const { return Size; }
   void clear();
index 63554fa39e6453f180df2c801c3ef24e1c3dfbf6..42292d42fb7946b6b64bcd5668031d5a86cbb905 100644 (file)
@@ -183,14 +183,14 @@ void StringTableBuilder::clear() {
   StringIndexMap.clear();
 }
 
-size_t StringTableBuilder::getOffset(StringRef S) const {
+size_t StringTableBuilder::getOffset(CachedHashString S) const {
   assert(isFinalized());
   auto I = StringIndexMap.find(S);
   assert(I != StringIndexMap.end() && "String is not in table!");
   return I->second;
 }
 
-size_t StringTableBuilder::add(StringRef S) {
+size_t StringTableBuilder::add(CachedHashString S) {
   if (K == WinCOFF)
     assert(S.size() > COFF::NameSize && "Short string in COFF string table!");