drastic slowdown for copies

Momo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 28 14:38:22 PDT 2015


On Thursday, 28 May 2015 at 21:27:42 UTC, Adam D. Ruppe wrote:
> 16 bytes is 64 bit - the same size as a reference. So copying 
> it is overall a bit less work - sending a 64 bit struct is as 
> small as a 64 bit reference and you don't go through the 
> pointer.
>
> So up to them, it is a bit faster.
>
>
> Add another byte and now the copy is too big to fit in a 
> register, so it needs to spill over into somewhere else which 
> means a bunch more work for the cpu.

But even in release mode (and with optimizations turned on) it is 
 > 3 times slower. Can I somehow enforce references, like in C++? 
I tried already in ref, const ref and immutable ref, nothing 
works.


More information about the Digitalmars-d-learn mailing list