• Nigel Tao's avatar
    image/png: optimize paeth some more. · dbcdce58
    Nigel Tao authored
    filterPaeth takes []byte arguments instead of byte arguments,
    which avoids some redudant computation of the previous pixel
    in the inner loop.
    
    Also eliminate a bounds check in decoding the up filter.
    
    benchmark                       old ns/op    new ns/op    delta
    BenchmarkDecodeGray               3139636      2812531  -10.42%
    BenchmarkDecodeNRGBAGradient     12341520     10971680  -11.10%
    BenchmarkDecodeNRGBAOpaque       10740780      9612455  -10.51%
    BenchmarkDecodePaletted           1819535      1818913   -0.03%
    BenchmarkDecodeRGB                8974695      8178070   -8.88%
    
    R=rsc
    CC=golang-dev
    https://golang.org/cl/6243061
    dbcdce58
paeth.go 1.42 KB