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 0;
204 unsigned *NewHashArray = (
unsigned *)(NewTableArray + NewSize + 1);
213 unsigned FullHash = HashTable[
I];
214 unsigned NewBucket = FullHash & (NewSize-1);
215 if (NewTableArray[NewBucket] == 0) {
216 NewTableArray[FullHash & (NewSize-1)] = Bucket;
217 NewHashArray[FullHash & (NewSize-1)] = FullHash;
222 unsigned ProbeSize = 1;
224 NewBucket = (NewBucket + ProbeSize++) & (NewSize-1);
225 }
while (NewTableArray[NewBucket]);
228 NewTableArray[NewBucket] = Bucket;
229 NewHashArray[NewBucket] = FullHash;
StringMapImpl(unsigned itemSize)
static unsigned HashString(StringRef Str, unsigned Result=0)
#define LLVM_LIKELY(EXPR)
int FindKey(StringRef Key) const
unsigned LookupBucketFor(StringRef Key)
StringMapEntryBase ** TheTable
initializer< Ty > init(const Ty &Val)
void RemoveKey(StringMapEntryBase *V)
static StringMapEntryBase * getTombstoneVal()
unsigned getKeyLength() const
StringMapEntryBase - Shared base class of StringMapEntry instances.
void *calloc(size_t count, size_t size);