From: Rafael Espindola Date: Wed, 5 Oct 2016 18:46:21 +0000 (+0000) Subject: Allow the caller to pass in the hash. X-Git-Tag: llvmorg-4.0.0-rc1~8010 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37fc0183d711b8aa3a3d09b3dad413ad10c3b297;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 283359 --- diff --git a/llvm/include/llvm/MC/StringTableBuilder.h b/llvm/include/llvm/MC/StringTableBuilder.h index 90d1bc3..e63a353 100644 --- a/llvm/include/llvm/MC/StringTableBuilder.h +++ b/llvm/include/llvm/MC/StringTableBuilder.h @@ -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(); diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp index 63554fa..42292d4 100644 --- a/llvm/lib/MC/StringTableBuilder.cpp +++ b/llvm/lib/MC/StringTableBuilder.cpp @@ -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!");