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

Commit 689e334

Browse files
committed
idxfile: optimise allocations in readObjectNames
This makes all the required Entry allocations in one go, instead of huge amounts of small individual allocations. Signed-off-by: David Symonds <dsymonds@golang.org>
1 parent 57570e8 commit 689e334

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plumbing/format/idxfile/decoder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"io"
88

9-
"gopkg.in/src-d/go-git.v4/plumbing"
109
"gopkg.in/src-d/go-git.v4/utils/binary"
1110
)
1211

@@ -98,13 +97,14 @@ func readFanout(idx *Idxfile, r io.Reader) error {
9897

9998
func readObjectNames(idx *Idxfile, r io.Reader) error {
10099
c := int(idx.ObjectCount)
100+
new := make([]Entry, c)
101101
for i := 0; i < c; i++ {
102-
var ref plumbing.Hash
103-
if _, err := io.ReadFull(r, ref[:]); err != nil {
102+
e := &new[i]
103+
if _, err := io.ReadFull(r, e.Hash[:]); err != nil {
104104
return err
105105
}
106106

107-
idx.Entries = append(idx.Entries, &Entry{Hash: ref})
107+
idx.Entries = append(idx.Entries, e)
108108
}
109109

110110
return nil

0 commit comments

Comments
 (0)