Efficient way to pass struct as parameter

Tim Hsu tim37021 at gmail.com
Wed Jan 3 07:02:28 UTC 2018


On Tuesday, 2 January 2018 at 22:49:20 UTC, Adam D. Ruppe wrote:
> On Tuesday, 2 January 2018 at 22:17:14 UTC, Johan Engelen wrote:
>> Pass the Vector3f by value.
>
> This is very frequently the correct answer to these questions! 
> Never assume ref is faster if speed matters - it may not be.

However speed really matters for me. I am writing a path tracing 
program. Ray will be constructed million of times during 
computation. And will be passed to functions to test intersection 
billion of times. After Reading comments here, it seems ray will 
be passed by value to the intersection testing function. I am not 
sure if ray is small enough to be passed by value. It needs some 
experiment.


More information about the Digitalmars-d-learn mailing list