Array append performance

Lionello Lunesu lionello at lunesu.remove.com
Thu Aug 28 04:09:29 PDT 2008


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:g95mh3$2e5i$2 at digitalmars.com...
> Essentially, I'm having a real hard time believing that for the 4 byte 
> case, memcpy is faster. Take a look at the actual implementation of 
> memcpy, vs the code generated by the compiler.

I agree with you, but I've noticed the byte[] = byte[] emits "rep movsb" and 
that must be the slowest way there is to copy 4 bytes. In fact, from my demo 
scene experience I've learned to not use those CISC instructions like rep 
and movs* and loop. mov/dec/jnz always proved faster.

However, I do think that it's a good idea to move the []=[] code into the 
run-time library. That way specialized versions can be written, like the 
other array operations. (Maybe it's already in the lib, but I haven't found 
it. I've only seen mention of OPmemcpy in e2ir.c which I assume represents 
the asm code for a memcpy.)

L. 




More information about the Digitalmars-d mailing list