aboutsummaryrefslogtreecommitdiffstats
path: root/formats/idxfile/idxfile.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-09 02:48:01 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-09 02:48:01 +0200
commit59219f01bbf5f748876258fe5f4648d2cfd4d6e9 (patch)
treeec225373a7cef5187a26666ff0e2607539a050cd /formats/idxfile/idxfile.go
parent3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01 (diff)
downloadgo-git-59219f01bbf5f748876258fe5f4648d2cfd4d6e9.tar.gz
format: idxfile.Encoder fix fanout generator
Diffstat (limited to 'formats/idxfile/idxfile.go')
-rw-r--r--formats/idxfile/idxfile.go13
1 files changed, 3 insertions, 10 deletions
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