TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: HERMAN SCHONFELD
from: ERIK WARMELINK
date: 1997-05-07 05:00:00
subject: DJGPP OPTIMIZATIONS

Herman, you wrote to Darin McBride:
 HS> Since you obviously fail to comprehend this I shall demonstrate.
 HS> Loop1 :-
 HS> #define bSize(99999)
There isn't anything to optimize. Macro parameters should be identifiers. ;-)
 HS> Oh, but you being so proffessional and all, you probably
 HS> implement loops that look like this..
  HS> Loop2 :-
I would use memcpy() since I know the arrays don't overlap. It is shorter, 
better readable and probably faster. 
 HS> Loop3 :-
Why waste all that precious space, watch your cache and use Duff's device
/* original code by Tom Duff, adapted from the Jargon File */
/* I am not sure whether it is PD */
   int n = (bufSize+3)/4;
   char *to=buf1, *from=buf2;
   assert ( bufSize > 0 );
   switch ( bufSize % 4 )
   {
   case 0:        do {  *to++ = *from++;
   case 3:              *to++ = *from++;
   case 2:              *to++ = *from++;
   case 1:              *to++ = *from++;
                      } while ( n-- > 0 );
   }
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™.