www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/14/15:23:46

Xref: news2.mv.net comp.os.msdos.djgpp:4968
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Speed optimization: memcpy() or for loop ??
Date: Thu, 13 Jun 1996 23:13:22 +0100
Organization: The University of York, UK
Lines: 33
Message-ID: <Pine.SGI.3.91.960613230307.20362B-100000@tower.york.ac.uk>
NNTP-Posting-Host: tower.york.ac.uk
Mime-Version: 1.0
In-Reply-To: <slrn4s0o6h.71s.davis@aluche.mit.edu>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 13 Jun 1996, John E. Davis wrote:

> Also, if n is a multiple of 2, one could do:
> 
>      diff = py - px;
>      pxmax = px + n;
>      while (px < pxmax) 
>        {
>          *(px + diff) = *px;
> 	 px++;
>          *(px + diff) = *px;
> 	 px++;
>        }

I think you people are seriously underestimating the power of gcc's 
optimiser. It is _good_ :-) Tricks like this may occasionally gain a slight 
speed increase, but in most cases gcc will do them for you if you just 
write your loop in the simple and obvious way. Making something this 
complicated can even be counterproductive: it obscures what you are 
trying to do, so the optimiser is less likely to figure out ways to make it 
faster.

You wouldn't be an ex-Borland user, by any chance? I notice people who 
have used Borland usually have a hard time trusting the compiler to produce 
good code without lots of help :-)


/*
 *	Shawn Hargreaves.        Why is 'phonetic' spelt with a ph?
 *	Check out Allegro and FED on http://www.york.ac.uk/~slh100/
 */



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019