[llvm] r283359 - Allow the caller to pass in the hash.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 11:46:22 PDT 2016


Author: rafael
Date: Wed Oct  5 13:46:21 2016
New Revision: 283359

URL: http://llvm.org/viewvc/llvm-project?rev=283359&view=rev
Log:
Allow the caller to pass in the hash.

If the caller already has the hash we don't have to compute it. This
will be used in lld.

Modified:
    llvm/trunk/include/llvm/MC/StringTableBuilder.h
    llvm/trunk/lib/MC/StringTableBuilder.cpp

Modified: llvm/trunk/include/llvm/MC/StringTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/StringTableBuilder.h?rev=283359&r1=283358&r2=283359&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/StringTableBuilder.h (original)
+++ llvm/trunk/include/llvm/MC/StringTableBuilder.h Wed Oct  5 13:46:21 2016
@@ -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();

Modified: llvm/trunk/lib/MC/StringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/StringTableBuilder.cpp?rev=283359&r1=283358&r2=283359&view=diff
==============================================================================
--- llvm/trunk/lib/MC/StringTableBuilder.cpp (original)
+++ llvm/trunk/lib/MC/StringTableBuilder.cpp Wed Oct  5 13:46:21 2016
@@ -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!");
 




More information about the llvm-commits mailing list