From 3a1614844785bccfe30221a69ec7f268f3912ad5 Mon Sep 17 00:00:00 2001 From: Matthew Dawson Date: Fri, 12 Jan 2018 01:21:39 -0500 Subject: [PATCH] archiver/archiver: Use Index.Has() instead of Index.Lookup() in isKnownBlob Index.Has() is a faster then Index.Lookup() for checking if a blob exists in the index. As the returned data is never used, this avoids a ton of allocations. --- internal/archiver/archiver.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/archiver/archiver.go b/internal/archiver/archiver.go index d64702bb7..b1e612409 100644 --- a/internal/archiver/archiver.go +++ b/internal/archiver/archiver.go @@ -86,8 +86,7 @@ func (arch *Archiver) isKnownBlob(id restic.ID, t restic.BlobType) bool { arch.knownBlobs.Insert(id) - _, found := arch.repo.Index().Lookup(id, t) - if found { + if arch.repo.Index().Has(id, t) { return true }