]> Cypherpunks repositories - gostls13.git/commitdiff
compress/flate: use correct table for size estimation
authorKlaus Post <klauspost@gmail.com>
Sat, 15 Oct 2016 11:06:22 +0000 (13:06 +0200)
committerNigel Tao <nigeltao@golang.org>
Mon, 17 Oct 2016 09:00:41 +0000 (09:00 +0000)
The incorrect table was used for estimating output size.
This can give suboptimal selection of entropy encoder in rare cases.

Change-Id: I8b358200f2d1f9a3f9b79a44269d7be704e1d2d9
Reviewed-on: https://go-review.googlesource.com/31172
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/compress/flate/huffman_bit_writer.go

index d8b5a3ebd7b50c7da64274dca161241e1bbb4d60..6cd6281249b8d5af20215893253270d1936f90e6 100644 (file)
@@ -520,7 +520,7 @@ func (w *huffmanBitWriter) writeBlockDynamic(tokens []token, eof bool, input []b
        // the literalEncoding and the offsetEncoding.
        w.generateCodegen(numLiterals, numOffsets, w.literalEncoding, w.offsetEncoding)
        w.codegenEncoding.generate(w.codegenFreq[:], 7)
-       size, numCodegens := w.dynamicSize(w.literalEncoding, huffOffset, 0)
+       size, numCodegens := w.dynamicSize(w.literalEncoding, w.offsetEncoding, 0)
 
        // Store bytes, if we don't get a reasonable improvement.
        if ssize, storable := w.storedSize(input); storable && ssize < (size+size>>4) {