• Joe Tsai's avatar
    compress/flate: extract LZ77 dictionary logic into seperate struct · 5fc4decd
    Joe Tsai authored
    The LZ77 portion of DEFLATE is relatively self-contained. For the
    decompression side of things, we extract this logic out for the
    following reasons:
    * It is easier to test just the LZ77 portion of the logic.
    * It reduces the noise in the inflate.go
    
    Also, we adjust the way that callbacks are handled in the inflate.
    Instead of using functions to abstract the logical componets of
    huffmanBlock(), use goto statements to jump between the necessary
    sections. This is faster since it avoids a function call and is
    arguably more readable.
    
    benchmark                              old MB/s     new MB/s     speedup
    BenchmarkDecodeDigitsSpeed1e4-4        53.62        60.11        1.12x
    BenchmarkDecodeDigitsSpeed1e5-4        61.90        69.07        1.12x
    BenchmarkDecodeDigitsSpeed1e6-4        63.24        70.58        1.12x
    BenchmarkDecodeDigitsDefault1e4-4      54.10        59.00        1.09x
    BenchmarkDecodeDigitsDefault1e5-4      69.50        74.07        1.07x
    BenchmarkDecodeDigitsDefault1e6-4      71.54        75.85        1.06x
    BenchmarkDecodeDigitsCompress1e4-4     54.39        58.94        1.08x
    BenchmarkDecodeDigitsCompress1e5-4     69.21        73.96        1.07x
    BenchmarkDecodeDigitsCompress1e6-4     71.14        75.75        1.06x
    BenchmarkDecodeTwainSpeed1e4-4         53.15        58.13        1.09x
    BenchmarkDecodeTwainSpeed1e5-4         66.56        72.29        1.09x
    BenchmarkDecodeTwainSpeed1e6-4         69.13        75.11        1.09x
    BenchmarkDecodeTwainDefault1e4-4       56.00        60.23        1.08x
    BenchmarkDecodeTwainDefault1e5-4       77.84        82.27        1.06x
    BenchmarkDecodeTwainDefault1e6-4       82.07        86.85        1.06x
    BenchmarkDecodeTwainCompress1e4-4      56.13        60.38        1.08x
    BenchmarkDecodeTwainCompress1e5-4      78.23        82.62        1.06x
    BenchmarkDecodeTwainCompress1e6-4      82.38        86.73        1.05x
    
    Change-Id: I8c6ae0e6bed652dd0570fc113c999977f5e71636
    Reviewed-on: https://go-review.googlesource.com/16528Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    Run-TryBot: Matthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    5fc4decd
dict_decoder.go 6.03 KB