v1.0.5 hashing improvements and fix
- fix hashing on ARM CPUs
- optimize hashing by using specialized xxhash implementations
- reduce variable allocations in get functions
- removed obsolete 0 length checks
It is noticeable faster than the current version of HaxMap is able to handle collisions of valid 0 hash values:
BenchmarkReadHashMapUint-8 1314156 955.6 ns/op
BenchmarkReadHaxMapUint-8 872134 1316 ns/op (can not handle hash 0 collisions)
// works for this library, fails for HaxMap
func TestHash0Collision(t *testing.T) {
m := New[string, int]()
staticHasher := func(key string) uintptr {
return 0
}
m.SetHasher(staticHasher)
m.Set("1", 1)
m.Set("2", 2)
_, ok := m.Get("1")
if !ok {
t.Error("1 not found")
}
_, ok = m.Get("2")
if !ok {
t.Error("2 not found")
}
}