Re:Latency numbers every programmer should know
by njs12345 on Thursday May 31, 2012 @10:50AM
(#4048268)
No, this form of strength reduction can often eliminate modulo operations in a loop even when the modulus is not a constant. The example given is:
which is optimised to this, without a modulo in sight:
I find the modulo easier to read in this case, but I guess that's a question of taste. It's certainly not 'wrong' to use a modulo, and probably worth the trade off in most cases if it makes your code clearer.
[ Parent
| on HN ]