From b18457df6a1f75283d95999fde5c162ba1a19651 Mon Sep 17 00:00:00 2001 From: Jeremy Stribling Date: Wed, 29 Nov 2017 13:57:36 -0800 Subject: storage: some minor code cleanup Suggested by mcuadros. Issue: #669 --- prune.go | 6 +----- storage/filesystem/object.go | 9 +++------ storage/memory/storage.go | 3 +-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/prune.go b/prune.go index fce3bfd..81f2582 100644 --- a/prune.go +++ b/prune.go @@ -28,7 +28,7 @@ func (r *Repository) Prune(opt PruneOptions) error { return err } // Now walk all (loose) objects in storage. - err = r.Storer.ForEachObjectHash(func(hash plumbing.Hash) error { + return r.Storer.ForEachObjectHash(func(hash plumbing.Hash) error { // Get out if we have seen this object. if pw.isSeen(hash) { return nil @@ -49,8 +49,4 @@ func (r *Repository) Prune(opt PruneOptions) error { } return opt.Handler(hash) }) - if err != nil { - return err - } - return nil } diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index 34501ec..6ca67cc 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -509,13 +509,10 @@ func hashListAsMap(l []plumbing.Hash) map[plumbing.Hash]bool { func (s *ObjectStorage) ForEachObjectHash(fun func(plumbing.Hash) error) error { err := s.dir.ForEachObjectHash(fun) - if err != nil { - if err == storer.ErrStop { - return nil - } - return err + if err == storer.ErrStop { + return nil } - return nil + return err } func (s *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) { diff --git a/storage/memory/storage.go b/storage/memory/storage.go index c76d163..0f66f1e 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -116,8 +116,7 @@ func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.H } func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { - _, ok := o.Objects[h] - if !ok { + if _, ok := o.Objects[h]; !ok { return plumbing.ErrObjectNotFound } return nil -- cgit