• Artyom Pervukhin's avatar
    image/draw: reduce drawPaletted allocations for special source cases · 088209bb
    Artyom Pervukhin authored
    drawPaletted has to discover R,G,B,A color values of each source image
    pixel in a given rectangle. Doing that by calling image.Image.At()
    method returning color.Color interface is quite taxing allocation-wise
    since interface values go through heap. Introduce special cases for some
    concrete source types by fetching color values using type-specific
    methods.
    
    name        old time/op    new time/op    delta
    Paletted-4    7.62ms ± 4%    3.72ms ± 3%   -51.20%  (p=0.008 n=5+5)
    
    name        old alloc/op   new alloc/op   delta
    Paletted-4     480kB ± 0%       0kB ± 0%   -99.99%  (p=0.000 n=4+5)
    
    name        old allocs/op  new allocs/op  delta
    Paletted-4      120k ± 0%        0k ± 0%  -100.00%  (p=0.008 n=5+5)
    
    Updates #15759.
    
    Change-Id: I0ce1770ff600ac80599541aaad4c2c826855c8fb
    Reviewed-on: https://go-review.googlesource.com/72370Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
    088209bb
Name
Last commit
Last update
..
color Loading commit data...
draw Loading commit data...
gif Loading commit data...
internal/imageutil Loading commit data...
jpeg Loading commit data...
png Loading commit data...
testdata Loading commit data...
decode_example_test.go Loading commit data...
decode_test.go Loading commit data...
format.go Loading commit data...
geom.go Loading commit data...
geom_test.go Loading commit data...
image.go Loading commit data...
image_test.go Loading commit data...
names.go Loading commit data...
ycbcr.go Loading commit data...
ycbcr_test.go Loading commit data...