From cd126c2a588d00124d917fa25de199f254b9a110 Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 5 Oct 2018 09:16:48 +0200 Subject: [PATCH] swarm/storage: Delete gc items direct in loop --- swarm/storage/ldbstore.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index e2cfeb7adf..7413bc0a16 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -287,7 +287,6 @@ func (s *LDBStore) collectGarbage(ratio float32) { it := s.db.NewIterator() defer it.Release() - garbage := []*gcItem{} var gcnt uint64 maxGcnt := s.getGCCount() @@ -306,20 +305,9 @@ func (s *LDBStore) collectGarbage(ratio float32) { log.Trace("parse gc", "index", index, "po", po, "hash", hash) - gci := &gcItem{ - idxKey: keyIdx, - idx: index, - value: index.Access, // the smaller, the more likely to be gc'd. see sort comparator below. - po: po, - } - - garbage = append(garbage, gci) + s.delete(index, keyIdx, po) gcnt++ } - - for _, garbageItem := range garbage { - s.delete(garbageItem.idx, garbageItem.idxKey, garbageItem.po) - } } // Export writes all chunks from the store to a tar archive, returning the