3 ms·
> No, you don't need to measure that Just this evening I came across some code which pasted an image on top of a blue background (in Go) that set every individ
by zimpenfish 6y ago
> No, you don't need to measure that
Just this evening I came across some code which pasted an image on top of a blue background (in Go) that set every individual pixel to the background, then got every pixel from the source and set the corresponding pixel of the destination to that colour. I figured it'd be quicker to paste the source onto the destination with `image/draw`.
Turns out, if you're using NRGBA images, it's 40-50% slower. That's definitely an "obvious optimisation" that was proven wrong by measurement.
(If you're using RGBA images, though, the pasting method is 300% faster. Because obviously.)