Carey, you wrote to me:
EW>Why waste all that precious space, watch your cache and use Duff's device
CB> For one thing, Duff's device is slower than what it should be.
I agree on that. I should have made it clearer I was a bit sarcastic.
CB> Second, jumping into a middle of a loop like is _not_ good
CB> practice. Not even close! Code like that is very close to
CB> being illegal. It's not, but it's close, and should be.
And I did even use braces around one single do-while statement to make the
switch() more readable. ;-)
More seriously, I consider it worse then using goto's. I do use goto's
sometimes in plain C to avoid excessive indentation or source code length,
but in C++ destructors take away even that excuse.
CB> Third, it also prevents a smart compiler from recognizing
CB> what you are doing and optimizing for the style of code it
CB> generates. As an example of that, Jerry C. mentioned the
CB> other day that his compiler recognises a simple copy loop
CB> (ie: for (x=0;x with inline rep move instructions. (My older DJGPP
CB> doesn't.)
That is IMHO the biggest problem when trying to do peephole optimizations by
hand. It can make the code a bit faster for your computer using your
compiler. But more often than not, it will make the code slower for another
computer or other compiler.
Bye,
Erik
---
---------------
* Origin: WarmelinkE@vertis.nl (2:282/608.60)
|