diff options
author | Filip Navara <navara@emclient.com> | 2019-04-23 22:16:02 +0200 |
---|---|---|
committer | Filip Navara <navara@emclient.com> | 2019-04-23 22:16:38 +0200 |
commit | 809027f163d2b7732b50d9cf7bbc501cc8ed3a1b (patch) | |
tree | c67c7cf07418e6344e372fbe064072779d3d29f5 /plumbing | |
parent | cbcb609afe98bf45df9c6c3b49553a46f4e93a63 (diff) | |
download | go-git-809027f163d2b7732b50d9cf7bbc501cc8ed3a1b.tar.gz |
Add one more cache check to the iterator
Signed-off-by: Filip Navara <navara@emclient.com>
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/format/packfile/packfile.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/plumbing/format/packfile/packfile.go b/plumbing/format/packfile/packfile.go index 895c152..a9121c4 100644 --- a/plumbing/format/packfile/packfile.go +++ b/plumbing/format/packfile/packfile.go @@ -490,13 +490,23 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) { continue } } else { + if obj, ok := i.p.cacheGet(e.Hash); ok { + if obj.Type() != i.typ { + continue + } + return obj, nil + } + h, err := i.p.objectHeaderAtOffset(int64(e.Offset)) if err != nil { return nil, err } typ, err := i.p.getObjectType(h) - if err == nil && typ != i.typ { + if err != nil { + return nil, err + } + if typ != i.typ { continue } @@ -504,7 +514,7 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) { } } - obj, err := i.p.GetByOffset(int64(e.Offset)) + obj, err := i.p.objectAtOffset(int64(e.Offset), e.Hash) if err != nil { return nil, err } |