Download Latest Version v1.0.8 hashing improvements.zip (27.8 kB)
Email in envelope

Get an email when there's a new version of hashmap

Home / v1.0.5
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2022-08-28 912 Bytes
v1.0.5 hashing improvements and fix.tar.gz 2022-08-28 19.6 kB
v1.0.5 hashing improvements and fix.zip 2022-08-28 27.3 kB
Totals: 3 Items   47.8 kB 0
  • 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")
    }
}
Source: README.md, updated 2022-08-28