From e0a7852b8bfba882412e09bda94840ee82f1e903 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 26 May 2022 15:05:29 +0200 Subject: [PATCH] repository: remove unused (Master)Index.Count --- internal/repository/index.go | 9 --------- internal/repository/master_index.go | 13 ------------- internal/repository/master_index_test.go | 6 ------ internal/repository/repository_test.go | 2 +- internal/restic/repository.go | 1 - 5 files changed, 1 insertion(+), 30 deletions(-) diff --git a/internal/repository/index.go b/internal/repository/index.go index 92f0da0e9..fd7ac1b94 100644 --- a/internal/repository/index.go +++ b/internal/repository/index.go @@ -314,15 +314,6 @@ func (idx *Index) Packs() restic.IDSet { return packs } -// Count returns the number of blobs of type t in the index. -func (idx *Index) Count(t restic.BlobType) (n uint) { - debug.Log("counting blobs of type %v", t) - idx.m.Lock() - defer idx.m.Unlock() - - return idx.byType[t].len() -} - type packJSON struct { ID restic.ID `json:"id"` Blobs []blobJSON `json:"blobs"` diff --git a/internal/repository/master_index.go b/internal/repository/master_index.go index 171411bf4..4fdd4a0ce 100644 --- a/internal/repository/master_index.go +++ b/internal/repository/master_index.go @@ -158,19 +158,6 @@ func (mi *MasterIndex) Packs(packBlacklist restic.IDSet) restic.IDSet { return packs } -// Count returns the number of blobs of type t in the index. -func (mi *MasterIndex) Count(t restic.BlobType) (n uint) { - mi.idxMutex.RLock() - defer mi.idxMutex.RUnlock() - - var sum uint - for _, idx := range mi.idx { - sum += idx.Count(t) - } - - return sum -} - // Insert adds a new index to the MasterIndex. func (mi *MasterIndex) Insert(idx *Index) { mi.idxMutex.Lock() diff --git a/internal/repository/master_index_test.go b/internal/repository/master_index_test.go index d1f240063..0aeaf5eb1 100644 --- a/internal/repository/master_index_test.go +++ b/internal/repository/master_index_test.go @@ -122,12 +122,6 @@ func TestMasterIndex(t *testing.T) { rtest.Assert(t, blobs == nil, "Expected no blobs when fetching with a random id") _, found = mIdx.LookupSize(restic.NewRandomBlobHandle()) rtest.Assert(t, !found, "Expected no blobs when fetching with a random id") - - // Test Count - num := mIdx.Count(restic.DataBlob) - rtest.Equals(t, uint(2), num) - num = mIdx.Count(restic.TreeBlob) - rtest.Equals(t, uint(2), num) } func TestMasterMergeFinalIndexes(t *testing.T) { diff --git a/internal/repository/repository_test.go b/internal/repository/repository_test.go index f2c00a2e6..2265ba453 100644 --- a/internal/repository/repository_test.go +++ b/internal/repository/repository_test.go @@ -374,7 +374,7 @@ func benchmarkLoadIndex(b *testing.B, version uint) { id, err := repository.SaveIndex(context.TODO(), repo, idx) rtest.OK(b, err) - b.Logf("index saved as %v (%v entries)", id.Str(), idx.Count(restic.DataBlob)) + b.Logf("index saved as %v", id.Str()) fi, err := repo.Backend().Stat(context.TODO(), restic.Handle{Type: restic.IndexFile, Name: id.String()}) rtest.OK(b, err) b.Logf("filesize is %v", fi.Size) diff --git a/internal/restic/repository.go b/internal/restic/repository.go index 0e388bb5d..fea151164 100644 --- a/internal/restic/repository.go +++ b/internal/restic/repository.go @@ -76,7 +76,6 @@ type PackBlobs struct { type MasterIndex interface { Has(BlobHandle) bool Lookup(BlobHandle) []PackedBlob - Count(BlobType) uint // Each returns a channel that yields all blobs known to the index. When // the context is cancelled, the background goroutine terminates. This