aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-06-05 10:51:26 +0200
committerGitHub <noreply@github.com>2018-06-05 10:51:26 +0200
commit8955f060a3cba36a56ac334576eba4123f6e918a (patch)
tree1c0f6bde136b50868b42248cb989c1d3ac84dbcd
parent57570e84f8c5739f0f4a59387493e590e709dde9 (diff)
parent689e334b51565dda54fcd44b2bf14da99eed61bb (diff)
downloadgo-git-8955f060a3cba36a56ac334576eba4123f6e918a.tar.gz
Merge pull request #845 from dsymonds/master
idxfile: optimise allocations in readObjectNames
-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