From 9a7056a4790ea27c109d6594cbf38b1e34ad4873 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 30 May 2023 20:13:33 +0200 Subject: [PATCH] index: implement indexmap.grow() without random access --- internal/index/indexmap.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/index/indexmap.go b/internal/index/indexmap.go index 15f253d76..c709f7b3a 100644 --- a/internal/index/indexmap.go +++ b/internal/index/indexmap.go @@ -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 } }