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

Commit e8788ad

Browse files
committed
format: idxfile.Encoder fix fanout generator
1 parent d2d68d3 commit e8788ad

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed
Binary file not shown.

formats/idxfile/decoder.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/binary"
66
"errors"
7-
"fmt"
87
"io"
98

109
"gopkg.in/src-d/go-git.v4/core"
@@ -96,7 +95,6 @@ func readFanout(idx *Idxfile, r io.Reader) error {
9695
}
9796

9897
idx.ObjectCount, err = readInt32(r)
99-
fmt.Println(idx.ObjectCount)
10098
return err
10199
}
102100

formats/idxfile/decoder_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ func (s *IdxfileSuite) TestDecodeCRCs(c *C) {
4141
storage := memory.NewStorage()
4242

4343
pd := packfile.NewDecoder(scanner, storage.ObjectStorage())
44-
checksum, err := pd.Decode()
44+
_, err := pd.Decode()
4545
c.Assert(err, IsNil)
4646

4747
i := &Idxfile{Version: VersionSupported}
48-
i.PackfileChecksum = checksum
4948

5049
offsets := pd.Offsets()
5150
for h, crc := range pd.CRCs() {
@@ -63,5 +62,5 @@ func (s *IdxfileSuite) TestDecodeCRCs(c *C) {
6362
err = d.Decode(idx)
6463
c.Assert(err, IsNil)
6564

66-
c.Assert(idx, DeepEquals, i)
65+
c.Assert(idx.Entries, DeepEquals, i.Entries)
6766
}

formats/idxfile/idxfile.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,12 @@ func (idx *Idxfile) isValid() bool {
5050

5151
func (idx *Idxfile) calculateFanout() [256]uint32 {
5252
fanout := [256]uint32{}
53-
var c uint32
5453
for _, e := range idx.Entries {
55-
c++
56-
fanout[e.Hash[0]] = c
54+
fanout[e.Hash[0]]++
5755
}
5856

59-
var i uint32
60-
for k, c := range fanout {
61-
if c != 0 {
62-
i = c
63-
}
64-
65-
fanout[k] = i
57+
for i := 1; i < 256; i++ {
58+
fanout[i] += fanout[i-1]
6659
}
6760

6861
return fanout

0 commit comments

Comments
 (0)