www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/12/21:41:13

From: Leath Muller <leathm AT gbrmpa DOT gov DOT au>
Message-Id: <199606130136.LAA22366@gbrmpa.gov.au>
Subject: Re: Speed optimization: memcpy() or for loop ??
To: djgpp AT delorie DOT com
Date: Thu, 13 Jun 1996 11:36:47 +1000 (EST)
In-Reply-To: <4pmscu$nrt@rs18.hrz.th-darmstadt.de> from "Alexander Lehmann" at Jun 12, 96 04:48:30 pm

> : For moving data, is it faster to use
> : a) memcpy(x,y,n*sizeof(x[0])) 
> : or 
> : b) for (i = 0; i < n; i++) x[i] = y[i];
> : or are they basically the same speed.

> (a) uses the function dj_movedata, which will use the repeat
> instruction to copy 4 byte values, which should be pretty fast.
 
> (b) requires a lots of address calculations, unless the compiler is
> very smart (I don't think so), but it can be sped up a bit at least
> (assuming that x and y are of type foo):
> *HACKED*

I know from experience that the first routine is faster...I wrote a blit
routine in true colour, using (b) first, and then changed the code to work
with (a), and (a) was about twice as fast...

Leathal.

- Raw text -


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