TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CAREY BLOODWORTH
from: ERIK WARMELINK
date: 1997-05-14 17:57:00
subject: DJGPP OPTIMIZATIONS

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.