From 59219f01bbf5f748876258fe5f4648d2cfd4d6e9 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Fri, 9 Sep 2016 02:48:01 +0200 Subject: format: idxfile.Encoder fix fanout generator --- formats/idxfile/idxfile.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'formats/idxfile/idxfile.go') 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 -- cgit