About ref used for performance reasons with struct

deadalnix deadalnix at gmail.com
Mon Feb 11 08:56:38 PST 2013


On Monday, 11 February 2013 at 16:51:22 UTC, Steven Schveighoffer 
wrote:
> On Mon, 11 Feb 2013 10:08:52 -0500, deadalnix 
> <deadalnix at gmail.com> wrote:
>
>> A good rule of thumb to know when to pass by ref for perf is :
>>  - The struct is big, or contains mixed entities (floats and 
>> ints). 2*size_t seems like a good heuristic from my experience.
>
> Array slices are 2*sizeof(size_t).  I would expect them to be 
> always copied and not ref'd.
>

First, they alway appears to be copied from the dev perspective. 
That why I put bunch of restrictions in the proposal.

Second, slice are 2*size_t and are not mixed entities (from CPU 
perspective, pointer are integers). So I don't have numbers, but 
I expect slice to be faster when passed by copy than when passed 
by ref.


More information about the Digitalmars-d mailing list