Mail Archives: djgpp/1996/12/21/17:26:01
Daniel Everton writes:
>In a program I'm currently writing I need to copy some biggish (64k)
>shunks of memory around. I'm using memcpy() at the moment but it's not
>quite fast enough. Is there some other function that any one can
I very much doubt you will be able to get anything faster than memcpy,
even if you do it all yourself in asm. As long as you are compiling with
optimisation (-O or -O2) gcc will inline the memcpy function into a
single rep ; movs, which is as fast as you can get. Although it just
occurs to me - this inlining might not happen if the size of the copy is
variable, so you should make sure you are using a constant block size.
The limiting factor here, though, is bus bandwidth rather than code
efficiency. If memcpy() isn't fast enough, I think you'll need to make
some improvements to your algorithm...
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -