Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Question on performance



       Dan,

> 	That will work well.  Not as efficient as not doing it,
> 	of course, but more efficient than you think.  Modern
> 	compilers are pretty routinely inlining that sort of
> 	thing so it should go better than even a simple user
> 	function call.  In fact, to aid it along, rather than
> 	writing it as a function call you might consider just
> 	using a #define.  Something like:
> 
> #define nan2zero(x) ((isnan(x))?0.0:x)
> 
> 	Then there is no function call in the first place.

with gcc -O3 writing a function gives no slowdown, since gcc is quite good
at automatic inlining.

Paul