3 ms·
"That has a performance impact on all platforms: the direct call to tmpfile() is now an indirect, which defeats optimization, and well, everything." This could
by exDM69 15y ago
"That has a performance impact on all platforms: the direct call to tmpfile() is now an indirect, which defeats optimization, and well, everything."
This couldn't be any more wrong. First of all, even if there were a performance impact, it would be meaningless compared to the time it takes to perform the system calls required for tmpfile().
Second, the compiler will inline the function call if it can. You can use a regular "inline" function and if you're not convinced it's good enough, then use __attribute__(force_inline) or equivalent. Even if the damn function is not an inline function, it will get inlined if it's in the same translation unit as where it is called (look at the asm output of gcc -O3). In the (not so far) future we'll be able to enjoy link time optimizations and don't have to care about translation units w.r.t. inlining optimizations.
- msftguy 15y agoEven without inlining, it will be subject to tail call elimination with any sane compiler: my_tmpfile will just branch to _imp_tmpfile instead or returning.