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

Commit 809027f

Browse files
committed
Add one more cache check to the iterator
Signed-off-by: Filip Navara <[email protected]>
1 parent cbcb609 commit 809027f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

plumbing/format/packfile/packfile.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,21 +490,31 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) {
490490
continue
491491
}
492492
} else {
493+
if obj, ok := i.p.cacheGet(e.Hash); ok {
494+
if obj.Type() != i.typ {
495+
continue
496+
}
497+
return obj, nil
498+
}
499+
493500
h, err := i.p.objectHeaderAtOffset(int64(e.Offset))
494501
if err != nil {
495502
return nil, err
496503
}
497504

498505
typ, err := i.p.getObjectType(h)
499-
if err == nil && typ != i.typ {
506+
if err != nil {
507+
return nil, err
508+
}
509+
if typ != i.typ {
500510
continue
501511
}
502512

503513
return i.p.getNextObject(h, e.Hash)
504514
}
505515
}
506516

507-
obj, err := i.p.GetByOffset(int64(e.Offset))
517+
obj, err := i.p.objectAtOffset(int64(e.Offset), e.Hash)
508518
if err != nil {
509519
return nil, err
510520
}

0 commit comments

Comments
 (0)