inline functions

Caligo iteronvexor at gmail.com
Fri Mar 25 19:04:20 PDT 2011


T[3] data;

T dot(const ref Vector o){
    return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * o.data[2];
}

T LengthSquared_Fast(){ return data[0] * data[0] + data[1] * data[1] +
data[2] * data[2]; }
T LengthSquared_Slow(){ return dot(this); }


The faster LengthSquared() is twice as fast, and I've test with GDC
and DMD.  Is it because the compilers don't inline-expand the dot()
function call?  I need the performance, but the faster version is too
verbose.


More information about the Digitalmars-d-learn mailing list