|
Posted by Andy Dingley on 10/14/14 11:23
On Mon, 08 Aug 2005 10:44:03 -0400, John Smith <noone@nowhere.net>
wrote:
>Furthermore, if you use "mod" instead of "and", you are doing the
>equivalent of a division operation on every loop iteration.
Do you have a hat ? Because if you do, and this makes the slightest
difference, then I'll eat it.
>"Mod" takes dozens of CPU cycles whereas "and" typically takes only one.
Agreed. But it's the 21st century - we have CPU cycles to burn! In
amongst all the many tasks going on to output a page, I will be _amazed_
if the overhead due to mod vs. and (which I'm sure is real) is anything
like significant.
Personally I'd stick with Mod, not And. This is for three reasons:
- It's clearer. Code that's self-explanatory always beats code that
needs a comment to explain it.
- Code with Mod is easily changed to put the stripes out every 3 or 5
lines. And isn't.
- And relies on "And" meaning a bitwise and on that platform, not a
logical and. That's a big assumption to make for long-term code that
might get ported.
Navigation:
[Reply to this message]
|