]> Cypherpunks repositories - gostls13.git/commitdiff
compress/flate: shrink decompressor struct for better performance
authorRyan Hitchman <hitchmanr@gmail.com>
Thu, 1 Nov 2012 17:57:24 +0000 (13:57 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 1 Nov 2012 17:57:24 +0000 (13:57 -0400)
Helps with issue 2703.

R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/5536078

src/pkg/compress/flate/inflate.go

index c7ef5ff7e6015fbf8c380b4b1eba8eaf204fe68b..c5a54b998fa7a948b658c46b63a39a66309fdc14 100644 (file)
@@ -208,8 +208,8 @@ type decompressor struct {
        h1, h2 huffmanDecoder
 
        // Length arrays used to define Huffman codes.
-       bits     [maxLit + maxDist]int
-       codebits [numCodes]int
+       bits     *[maxLit + maxDist]int
+       codebits *[numCodes]int
 
        // Output history, buffer.
        hist  *[maxHist]byte
@@ -692,6 +692,8 @@ func makeReader(r io.Reader) Reader {
 // finished reading.
 func NewReader(r io.Reader) io.ReadCloser {
        var f decompressor
+       f.bits = new([maxLit + maxDist]int)
+       f.codebits = new([numCodes]int)
        f.r = makeReader(r)
        f.hist = new([maxHist]byte)
        f.step = (*decompressor).nextBlock
@@ -707,6 +709,8 @@ func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser {
        var f decompressor
        f.r = makeReader(r)
        f.hist = new([maxHist]byte)
+       f.bits = new([maxLit + maxDist]int)
+       f.codebits = new([numCodes]int)
        f.step = (*decompressor).nextBlock
        f.setDict(dict)
        return &f