|
17 | 17 | #include "llvm/ADT/StringMapEntry.h"
|
18 | 18 | #include "llvm/ADT/iterator.h"
|
19 | 19 | #include "llvm/Support/AllocatorBase.h"
|
20 |
| -#include "llvm/Support/DJB.h" |
21 | 20 | #include "llvm/Support/PointerLikeTypeTraits.h"
|
22 | 21 | #include <initializer_list>
|
23 | 22 | #include <iterator>
|
@@ -61,20 +60,12 @@ class StringMapImpl {
|
61 | 60 | /// specified bucket will be non-null. Otherwise, it will be null. In either
|
62 | 61 | /// case, the FullHashValue field of the bucket will be set to the hash value
|
63 | 62 | /// of the string.
|
64 |
| - unsigned LookupBucketFor(StringRef Key) { |
65 |
| - return LookupBucketFor(Key, hash(Key)); |
66 |
| - } |
67 |
| - |
68 |
| - /// Overload that explicitly takes precomputed hash(Key). |
69 |
| - unsigned LookupBucketFor(StringRef Key, uint32_t FullHashValue); |
| 63 | + unsigned LookupBucketFor(StringRef Key); |
70 | 64 |
|
71 | 65 | /// FindKey - Look up the bucket that contains the specified key. If it exists
|
72 | 66 | /// in the map, return the bucket number of the key. Otherwise return -1.
|
73 | 67 | /// This does not modify the map.
|
74 |
| - int FindKey(StringRef Key) const { return FindKey(Key, hash(Key)); } |
75 |
| - |
76 |
| - /// Overload that explicitly takes precomputed hash(Key). |
77 |
| - int FindKey(StringRef Key, uint32_t FullHashValue) const; |
| 68 | + int FindKey(StringRef Key) const; |
78 | 69 |
|
79 | 70 | /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
|
80 | 71 | /// delete it. This aborts if the value isn't in the table.
|
@@ -103,13 +94,6 @@ class StringMapImpl {
|
103 | 94 | bool empty() const { return NumItems == 0; }
|
104 | 95 | unsigned size() const { return NumItems; }
|
105 | 96 |
|
106 |
| - /// Returns the hash value that will be used for the given string. |
107 |
| - /// This allows precomputing the value and passing it explicitly |
108 |
| - /// to some of the functions. |
109 |
| - /// The implementation of this function is not guaranteed to be stable |
110 |
| - /// and may change. |
111 |
| - static uint32_t hash(StringRef Key); |
112 |
| - |
113 | 97 | void swap(StringMapImpl &Other) {
|
114 | 98 | std::swap(TheTable, Other.TheTable);
|
115 | 99 | std::swap(NumBuckets, Other.NumBuckets);
|
@@ -231,19 +215,15 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
|
231 | 215 | StringMapKeyIterator<ValueTy>(end()));
|
232 | 216 | }
|
233 | 217 |
|
234 |
| - iterator find(StringRef Key) { return find(Key, hash(Key)); } |
235 |
| - |
236 |
| - iterator find(StringRef Key, uint32_t FullHashValue) { |
237 |
| - int Bucket = FindKey(Key, FullHashValue); |
| 218 | + iterator find(StringRef Key) { |
| 219 | + int Bucket = FindKey(Key); |
238 | 220 | if (Bucket == -1)
|
239 | 221 | return end();
|
240 | 222 | return iterator(TheTable + Bucket, true);
|
241 | 223 | }
|
242 | 224 |
|
243 |
| - const_iterator find(StringRef Key) const { return find(Key, hash(Key)); } |
244 |
| - |
245 |
| - const_iterator find(StringRef Key, uint32_t FullHashValue) const { |
246 |
| - int Bucket = FindKey(Key, FullHashValue); |
| 225 | + const_iterator find(StringRef Key) const { |
| 226 | + int Bucket = FindKey(Key); |
247 | 227 | if (Bucket == -1)
|
248 | 228 | return end();
|
249 | 229 | return const_iterator(TheTable + Bucket, true);
|
@@ -325,13 +305,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
|
325 | 305 | /// if and only if the insertion takes place, and the iterator component of
|
326 | 306 | /// the pair points to the element with key equivalent to the key of the pair.
|
327 | 307 | std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
|
328 |
| - return try_emplace_with_hash(KV.first, hash(KV.first), |
329 |
| - std::move(KV.second)); |
330 |
| - } |
331 |
| - |
332 |
| - std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV, |
333 |
| - uint32_t FullHashValue) { |
334 |
| - return try_emplace_with_hash(KV.first, FullHashValue, std::move(KV.second)); |
| 308 | + return try_emplace(KV.first, std::move(KV.second)); |
335 | 309 | }
|
336 | 310 |
|
337 | 311 | /// Inserts elements from range [first, last). If multiple elements in the
|
@@ -365,14 +339,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
|
365 | 339 | /// the pair points to the element with key equivalent to the key of the pair.
|
366 | 340 | template <typename... ArgsTy>
|
367 | 341 | std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
|
368 |
| - return try_emplace_with_hash(Key, hash(Key), std::forward<ArgsTy>(Args)...); |
369 |
| - } |
370 |
| - |
371 |
| - template <typename... ArgsTy> |
372 |
| - std::pair<iterator, bool> try_emplace_with_hash(StringRef Key, |
373 |
| - uint32_t FullHashValue, |
374 |
| - ArgsTy &&...Args) { |
375 |
| - unsigned BucketNo = LookupBucketFor(Key, FullHashValue); |
| 342 | + unsigned BucketNo = LookupBucketFor(Key); |
376 | 343 | StringMapEntryBase *&Bucket = TheTable[BucketNo];
|
377 | 344 | if (Bucket && Bucket != getTombstoneVal())
|
378 | 345 | return std::make_pair(iterator(TheTable + BucketNo, false),
|
|
0 commit comments