TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: HERMAN SCHONFELD
from: JERRY COFFIN
date: 1997-04-25 16:53:00
subject: Low level optimizatio 1/2

On (24 Apr 97) Herman Schonfeld wrote to Carey Bloodworth...
 CB>Let's work through a simple project.  Let's say that we need to
 CB>copy some data from one array to another.  Basically, just like
 CB>memcpy()
 HS> I don't need to be tutured!
Your messages indicate a need for tutoring in both programming and
spelling.
 CB>void memcpy(char to[], char from[], int len)
 CB>{ while (len--) to[len]=from[len];}
 HS> Sloppy code!
 HS> And you claim that optimization creates sloppy code.
I not only claim, but have _proven_ that what you claimed was
optimization produced extremely sloppy code that was considerably larger
and slower than the readable code you started with.
 HS> First off all, try unrolling the loop, and use pointer refferencing.
And be prepared for the code to be slower after you do so.  If you have
a compiler that can't unroll loops on its own, throw it away a get a
decent one instead.  My guess is that the only compilers around that
wont' do this on their own are stripped down versions with all or most
optimizations intentionally removed.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

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™.