Array append performance
Walter Bright
newshound1 at digitalmars.com
Thu Aug 28 12:00:03 PDT 2008
Lionello Lunesu wrote:
>
> "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.
But for 4 bytes, how much slower could it be than memcpy, which executes
a lot of setup code?
> 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.)
OPmemcpy is an operator supported by the compiler back end, it generates
the movsb's.
More information about the Digitalmars-d
mailing list