Replacing C's memcpy with a D implementation

Mike Franklin slavo5150 at yahoo.com
Sun Jun 10 13:45:54 UTC 2018


On Sunday, 10 June 2018 at 13:16:21 UTC, Adam D. Ruppe wrote:

> arr1[] = arr2[]; // the compiler makes this memcpy, the 
> optimzer can further do its magic

void memcpyD()
{
     dst = src.dup;
}

void memcpyD2()
{
     dst[] = src[];
}

-----
memcpyD: 1 ms, 725 μs, and 1 hnsec
memcpyD2: 587 μs and 5 hnsecs
memcpyASM: 119 μs and 5 hnsecs

Still, the ASM version is much faster.

btw, what's the difference between the two.  If you can't tell, 
I'm actually not a very good D programmer.

Mike





More information about the Digitalmars-d mailing list