copying memory in phobos
Mike
none at none.com
Tue Apr 8 05:35:00 PDT 2014
On Tuesday, 8 April 2014 at 11:56:43 UTC, ketmar wrote:
>> I understand that. But why is dest[] = src[] not good enough
>> for run-time?
> 'cause some compilers (gcc, for example) has memcpy() as
> 'intrinsic' and generates better inline code for it sometimes.
> it's just a small hint for compiler backend, and faster code is
> good, isn't it? ;-)
a[] = b[] causes the compiler to generate a call to _d_arraycopy,
and _d_arraycopy calls, you guessed it, memcpy! (verified with
GDC 4.8.2) So, there is no performance benefit calling memcpy
directly. It's going to be called anyway.
I'm beginning to believe that, at least in the code I posted,
memcpy can be replaced by the array syntax, removing a dependency
on the C library.
More information about the Digitalmars-d-learn
mailing list