in reply to Re: quickness is not so obvious
in thread quickness is not so obvious
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: quickness is not so obvious
by GrandFather (Saint) on Jan 23, 2015 at 11:09 UTC | |
by RonW (Parson) on Jan 23, 2015 at 18:04 UTC | |
by GrandFather (Saint) on Jan 24, 2015 at 05:44 UTC | |
by Athanasius (Archbishop) on Jan 24, 2015 at 07:05 UTC | |
by LanX (Saint) on Jan 24, 2015 at 07:48 UTC | |
by RonW (Parson) on Jan 24, 2015 at 19:47 UTC | |
by LanX (Saint) on Jan 24, 2015 at 19:55 UTC | |
|