Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
Add one more cache check to the iterator
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Navara <[email protected]>
  • Loading branch information
filipnavara committed Apr 23, 2019
1 parent cbcb609 commit 809027f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plumbing/format/packfile/packfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,21 +490,31 @@ 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
}

return i.p.getNextObject(h, e.Hash)
}
}

obj, err := i.p.GetByOffset(int64(e.Offset))
obj, err := i.p.objectAtOffset(int64(e.Offset), e.Hash)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 809027f

Please sign in to comment.