aboutsummaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
Diffstat (limited to 'formats')
-rw-r--r--formats/idxfile/decoder.go2
-rw-r--r--formats/idxfile/decoder_test.go5
-rw-r--r--formats/idxfile/idxfile.go13
3 files changed, 5 insertions, 15 deletions
diff --git a/formats/idxfile/decoder.go b/formats/idxfile/decoder.go
index 617c0f4..57b508d 100644
--- a/formats/idxfile/decoder.go
+++ b/formats/idxfile/decoder.go
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
"errors"
- "fmt"
"io"
"gopkg.in/src-d/go-git.v4/core"
@@ -96,7 +95,6 @@ func readFanout(idx *Idxfile, r io.Reader) error {
}
idx.ObjectCount, err = readInt32(r)
- fmt.Println(idx.ObjectCount)
return err
}
diff --git a/formats/idxfile/decoder_test.go b/formats/idxfile/decoder_test.go
index 5a844a3..cd90465 100644
--- a/formats/idxfile/decoder_test.go
+++ b/formats/idxfile/decoder_test.go
@@ -41,11 +41,10 @@ func (s *IdxfileSuite) TestDecodeCRCs(c *C) {
storage := memory.NewStorage()
pd := packfile.NewDecoder(scanner, storage.ObjectStorage())
- checksum, err := pd.Decode()
+ _, err := pd.Decode()
c.Assert(err, IsNil)
i := &Idxfile{Version: VersionSupported}
- i.PackfileChecksum = checksum
offsets := pd.Offsets()
for h, crc := range pd.CRCs() {
@@ -63,5 +62,5 @@ func (s *IdxfileSuite) TestDecodeCRCs(c *C) {
err = d.Decode(idx)
c.Assert(err, IsNil)
- c.Assert(idx, DeepEquals, i)
+ c.Assert(idx.Entries, DeepEquals, i.Entries)
}
diff --git a/formats/idxfile/idxfile.go b/formats/idxfile/idxfile.go
index ce4c976..65b58b5 100644
--- a/formats/idxfile/idxfile.go
+++ b/formats/idxfile/idxfile.go
@@ -50,19 +50,12 @@ func (idx *Idxfile) isValid() bool {
func (idx *Idxfile) calculateFanout() [256]uint32 {
fanout := [256]uint32{}
- var c uint32
for _, e := range idx.Entries {
- c++
- fanout[e.Hash[0]] = c
+ fanout[e.Hash[0]]++
}
- var i uint32
- for k, c := range fanout {
- if c != 0 {
- i = c
- }
-
- fanout[k] = i
+ for i := 1; i < 256; i++ {
+ fanout[i] += fanout[i-1]
}
return fanout