37 assert((InitSize & (InitSize-1)) == 0 &&
38 "Init Size must be a power of 2 or zero!");
65 unsigned BucketNo = FullHashValue & (HTSize-1);
68 unsigned ProbeAmt = 1;
69 int FirstTombstone = -1;
76 if (FirstTombstone != -1) {
77 HashTable[FirstTombstone] = FullHashValue;
78 return FirstTombstone;
81 HashTable[BucketNo] = FullHashValue;
87 if (FirstTombstone == -1) FirstTombstone = BucketNo;
88 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
96 char *ItemStr = (
char*)BucketItem+
ItemSize;
104 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
118 if (HTSize == 0)
return -1;
120 unsigned BucketNo = FullHashValue & (HTSize-1);
123 unsigned ProbeAmt = 1;
132 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
140 char *ItemStr = (
char*)BucketItem+
ItemSize;
148 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
159 const char *VStr = (
char*)V +
ItemSize;
162 assert(V == V2 &&
"Didn't find key?");
169 if (Bucket == -1)
return nullptr;
200 unsigned NewBucketNo = BucketNo;
206 unsigned *NewHashArray = (
unsigned *)(NewTableArray + NewSize + 1);
215 unsigned FullHash = HashTable[
I];
216 unsigned NewBucket = FullHash & (NewSize-1);
217 if (!NewTableArray[NewBucket]) {
218 NewTableArray[FullHash & (NewSize-1)] = Bucket;
219 NewHashArray[FullHash & (NewSize-1)] = FullHash;
221 NewBucketNo = NewBucket;
226 unsigned ProbeSize = 1;
228 NewBucket = (NewBucket + ProbeSize++) & (NewSize-1);
229 }
while (NewTableArray[NewBucket]);
232 NewTableArray[NewBucket] = Bucket;
233 NewHashArray[NewBucket] = FullHash;
235 NewBucketNo = NewBucket;
StringMapImpl(unsigned itemSize)
static unsigned HashString(StringRef Str, unsigned Result=0)
HashString - Hash function for strings.
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
StringMapEntryBase ** TheTable
initializer< Ty > init(const Ty &Val)
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it...
static StringMapEntryBase * getTombstoneVal()
unsigned getKeyLength() const
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringRef - Represent a constant reference to a string, i.e.