diff options
Diffstat (limited to 'formats/idxfile/idxfile.go')
-rw-r--r-- | formats/idxfile/idxfile.go | 13 |
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 |