Sometimes, implementation details do make a difference. Even with today's advanced optimizing compilers. And in the embedded systems world, where US$ 0.50 processors rule, the best available compilers often do not have the most advanced optimizers.
Example (in C):
i = count; j = 0; do { // something with j j++; } while (--i);
is often faster than the common: for (j = 0; j < count; j++) { } or even: for (i = count, j = 0; i; --i, j++) { }
This is because it's easy for an optimizer to "see" it can safely "replace" while (--i) with a decrement-and-branch-if-not-zero instruction.
(Also, if your code functions equally correctly with a decrementing "index", you can skip the extra variable and associated increment.)
In reply to Re^2: quickness is not so obvious
by RonW
in thread quickness is not so obvious
by DanBev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |