diff --git a/internal/repository/index/indexmap.go b/internal/repository/index/indexmap.go index d38385aba..f3db6ff5f 100644 --- a/internal/repository/index/indexmap.go +++ b/internal/repository/index/indexmap.go @@ -31,7 +31,7 @@ type indexMap struct { buckets []uint numentries uint - mh maphash.Hash + seed maphash.Seed blockList hashedArrayTree } @@ -176,15 +176,13 @@ func (m *indexMap) hash(id restic.ID) uint { // While SHA-256 should be collision-resistant, for hash table indices // we use only a few bits of it and finding collisions for those is // much easier than breaking the whole algorithm. - mh := maphash.Hash{} - mh.SetSeed(m.mh.Seed()) - _, _ = mh.Write(id[:]) - h := uint(mh.Sum64()) + h := uint(maphash.Bytes(m.seed, id[:])) return h & uint(len(m.buckets)-1) } func (m *indexMap) init() { const initialBuckets = 64 + m.seed = maphash.MakeSeed() m.buckets = make([]uint, initialBuckets) // first entry in blockList serves as null byte m.blockList = *newHAT()