HS>CB>void memcpy(char to[], char from[], int len)
HS>CB>{ while (len--) to[len]=from[len];}
HS>First off all, try unrolling the loop, and use pointer refferencing.
Unrolling can help. Pointers slow it down. I've timed it. Contrary to
popular convention, pointers are _not_ automatically faster than
indexing.
HS>But according to you, unrolling is bad, then use Duffs Device.
In some cases, yes. In other cases no. It depends a lot on how much
the loop does. This is especially true when you tell the compiler to
unroll loops with an optimization switch such as -O3 for DJGPP.
HS>CB>void memcpy(char *to, char *from,int len)
HS>CB>{ while (len--) *to++=*from++;}
HS>len needs not be used like that in a while statement like that.
HS>It uses a register (which could be used for something else) so remove it,
an
HS>restructure your loop.
Yes it does use a register. But even on the register poor x86
architecture, most compilers will keep all three variables in registers.
Only my 8 year old QC20 doesn't bother to keep _any_ of them in
registers.
--- QScan/PCB v1.19b / 01-0162
---------------
* Origin: Jackalope Junction 501-785-5381 Ft Smith AR (1:3822/1)
|