Efficient way to pass struct as parameter

Tim Hsu tim37021 at gmail.com
Tue Jan 2 18:21:13 UTC 2018


I am creating Vector3 structure. I use struct to avoid GC. 
However, struct will be copied when passed as parameter to 
function


struct Ray {
     Vector3f origin;
     Vector3f dir;

     @nogc @system
     this(Vector3f *origin, Vector3f *dir) {
         this.origin = *origin;
         this.dir = *dir;
     }
}

How can I pass struct more efficiently?


More information about the Digitalmars-d-learn mailing list