Seconded on the benchmark first suggestion. Baring that it'd be trivial to memoize the converted values if there's a high likelyhood that they'll show up repeatedly (then again you're wagering that the hash lookup and deref will be faster than 3 shifts and bitwise-ands, so again benchmark).
my %_pixel_as_rgb; for my $pixel ( @allpixels ) { push @rgbvals, @{ $_pixel_as_rgb{ $pixel } ||= [ $pixel >> 16 & 255, $pixel >> 8 +& 255, $pixel & 255 ] }; }
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: How to optimize this code
by Fletch
in thread How to optimize this code
by avo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |