Is there a way to do this more efficiently?Note that this involves lotsa fnstsw and conditional jumps, which suck.Code:inline void Clip( double &x, double a, double b ) // makes sure x is between a and b { if (x<a) x = a; else if (x>b) x = b; }
I personally (msvc8@core2duo) gain almost 50% speed increase if I do this:No status word crap, and no checks anymore.Code:inline void Clip( double &x, double a, double b ) // makes sure x is between a and b { x = b-x; x = (x+fabs(x))*0.5; // this essentially does "if (x<0) x=0;" x = b-x-a; x = (x+fabs(x))*0.5; x += a; }
Any other tricks to make this faster?



LinkBack URL
About LinkBacks



).