aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2018-05-30 10:34:28 +1000
committerDavid Symonds <dsymonds@golang.org>2018-05-30 10:34:32 +1000
commit689e334b51565dda54fcd44b2bf14da99eed61bb (patch)
tree1c0f6bde136b50868b42248cb989c1d3ac84dbcd /plumbing
parent57570e84f8c5739f0f4a59387493e590e709dde9 (diff)
downloadgo-git-689e334b51565dda54fcd44b2bf14da99eed61bb.tar.gz
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>
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/idxfile/decoder.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/plumbing/format/idxfile/decoder.go b/plumbing/format/idxfile/decoder.go
index f361213..45afb1e 100644
--- a/plumbing/format/idxfile/decoder.go
+++ b/plumbing/format/idxfile/decoder.go
@@ -6,7 +6,6 @@ import (
"errors"
"io"
- "gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/utils/binary"
)
@@ -98,13 +97,14 @@ func readFanout(idx *Idxfile, r io.Reader) error {
func readObjectNames(idx *Idxfile, r io.Reader) error {
c := int(idx.ObjectCount)
+ new := make([]Entry, c)
for i := 0; i < c; i++ {
- var ref plumbing.Hash
- if _, err := io.ReadFull(r, ref[:]); err != nil {
+ e := &new[i]
+ if _, err := io.ReadFull(r, e.Hash[:]); err != nil {
return err
}
- idx.Entries = append(idx.Entries, &Entry{Hash: ref})
+ idx.Entries = append(idx.Entries, e)
}
return nil