index: convert to implement modern go iterators

This commit is contained in:
Michael Eischer committed 2025-11-16 12:56:37 +01:00
1 parent 0624b656b8
commit 38c543457e
11 files changed
+124 -101

No files matched your search

+3 -4
View File
@@ -1,7 +1,6 @@
package index
import (
"context"
"sort"
"github.com/restic/restic/internal/restic"
@@ -120,17 +119,17 @@ func (a *AssociatedSet[T]) For(cb func(bh restic.BlobHandle, val T)) {
cb(k, v)
}
_ = a.idx.Each(context.Background(), func(pb restic.PackedBlob) {
for pb := range a.idx.Values() {
if _, ok := a.overflow[pb.BlobHandle]; ok {
// already reported via overflow set
return
continue
}
val, known := a.Get(pb.BlobHandle)
if known {
cb(pb.BlobHandle, val)
}
})
}
}
// List returns a sorted slice of all BlobHandle in the set.