• Nigel Tao's avatar
    compress/lzw: don't use a closure in NewReader, which avoids having · fdbbb066
    Nigel Tao authored
    to move some variables from the stack to the heap.
    
    Sorted benchmark runs on my 2007-era Mac Mini (GOARCH=amd64, GOOS=linux):
    
    Before:
    lzw.BenchmarkDecoder        2000        878176 ns/op
    lzw.BenchmarkDecoder        2000        878415 ns/op
    lzw.BenchmarkDecoder        2000        880352 ns/op
    lzw.BenchmarkDecoder        2000        898445 ns/op
    lzw.BenchmarkDecoder        2000        901728 ns/op
    
    After:
    lzw.BenchmarkDecoder        2000        859065 ns/op
    lzw.BenchmarkDecoder        2000        859402 ns/op
    lzw.BenchmarkDecoder        2000        860035 ns/op
    lzw.BenchmarkDecoder        2000        860555 ns/op
    lzw.BenchmarkDecoder        2000        861109 ns/op
    
    The ratio of before/after median times is 1.024.
    
    The runtime.MemStats.Mallocs delta per loop drops from 109 to 104.
    
    R=r, r2, dfc
    CC=golang-dev
    https://golang.org/cl/4253043
    fdbbb066
Name
Last commit
Last update
doc Loading commit data...
include Loading commit data...
lib Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...