index: implement indexmap.grow() without random access

This commit is contained in:
Michael Eischer 2023-05-30 20:13:33 +02:00
parent fc05e35a08
commit 9a7056a479

View file

@ -99,18 +99,15 @@ func (m *indexMap) get(id restic.ID) *indexEntry {
}
func (m *indexMap) grow() {
old := m.buckets
m.buckets = make([]uint, growthFactor*len(m.buckets))
for _, ei := range old {
for ei != 0 {
e := m.resolve(ei)
h := m.hash(e.id)
next := e.next
e.next = m.buckets[h]
m.buckets[h] = ei
ei = next
}
blockCount := m.blockList.Size()
for i := uint(1); i < blockCount; i++ {
e := m.resolve(i)
h := m.hash(e.id)
e.next = m.buckets[h]
m.buckets[h] = i
}
}