About ref used for performance reasons with struct

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Mon Feb 11 13:45:11 PST 2013


On Mon, 11 Feb 2013 07:52:28 +0100
"deadalnix" <deadalnix at gmail.com> wrote:

> Ok, We have 2 usages of ref : when you actually need to modify 
> informations, and for performance reasons. Let's talk about the 
> second one.
> 
> Passing by ref to improve performance is not ideal. First this is 
> quite hard to know when it is actually faster to pass by ref and 
> to pass by value, especially in generic code. Secondly it is easy 
> to forget to use ref at some location, and a lot of small 
> performance improvement are lost in the process. Finally, this 
> may be error prone.
> 
> I'm thinking about it for a while now and I'm now convinced that 
> we should allow the compiler to do that job for us. Let me 
> explain.
> 

To be honest, up until recently, I mistakenly thought the compiler DID
do this. (Yea, my mistake.)

Is it possible I had confused structs with static arrays? Do static
arrays do that?



More information about the Digitalmars-d mailing list