We don't bite newbies here... much | |
PerlMonks |
Re^2: Challenge: CPU-optimized byte-wise or-equals (for a meter of beer)by moritz (Cardinal) |
on Sep 12, 2007 at 14:50 UTC ( [id://638583]=note: print w/replies, xml ) | Need Help?? |
Since there are not so many bytes to substitute it pays off to search for these rare cases instead of working "blindly" with bit ops.
Creating $mask takes one pass through the string, and then there are three binary bit ops on the string(s). That makes four passes, while only 1/256 of the bytes being zero bytes. Thus a solution that actually looks for zeros (one pass) may have an overhead of 3*256 compared to the bit operations to be still as fast. (Rough estimation only)
In Section
Seekers of Perl Wisdom
|
|