optimize vector code

Bill Baxter dnewsgroup at billbaxter.com
Fri Nov 30 09:28:49 PST 2007


Sascha Katzner wrote:
> Bill Baxter wrote:
>> Pass big structs by reference.
>>      void opAddAssign(ref Vector3 v) {...
> 
> In this example this is not a good idea, because it prevents that the 
> compiler inlines opAddAssign(). Don't know why, but it does.
> 
> yourSuggestion.sizeof = 0x38 + 0x23 = 0x5b bytes ;-)
> 
> LLAP,
> Sascha

All I know is that actual benchmarking has been done on raytracers and 
changing all the pass-by-values to pass-by-ref improved speed.

I have no idea what your sizeof is benchmarking there.  But if you're 
interested in actual execution speed I suggest measuring time rather 
than bytes.  I'd be very interested to know if pass-by-ref is no longer 
faster than pass-by-value for big structs.

--bb


More information about the Digitalmars-d-learn mailing list