|
|
@ -152,28 +152,6 @@ func (c *Compiler) emitMapDelete(keyType types.Type, m, key llvm.Value, pos toke |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Get FNV-1a hash of this string.
|
|
|
|
//
|
|
|
|
// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash
|
|
|
|
func hashmapHash(data []byte) uint32 { |
|
|
|
var result uint32 = 2166136261 // FNV offset basis
|
|
|
|
for _, c := range data { |
|
|
|
result ^= uint32(c) |
|
|
|
result *= 16777619 // FNV prime
|
|
|
|
} |
|
|
|
return result |
|
|
|
} |
|
|
|
|
|
|
|
// Get the topmost 8 bits of the hash, without using a special value (like 0).
|
|
|
|
func hashmapTopHash(hash uint32) uint8 { |
|
|
|
tophash := uint8(hash >> 24) |
|
|
|
if tophash < 1 { |
|
|
|
// 0 means empty slot, so make it bigger.
|
|
|
|
tophash += 1 |
|
|
|
} |
|
|
|
return tophash |
|
|
|
} |
|
|
|
|
|
|
|
// Returns true if this key type does not contain strings, interfaces etc., so
|
|
|
|
// can be compared with runtime.memequal.
|
|
|
|
func hashmapIsBinaryKey(keyType types.Type) bool { |
|
|
|