c++ - can overuse in Macros hurt performance? -
i have long code, being called millions of time, have noticed if change macros inline functions code runs lot faster.
can explain why is? aren't macros text replacement? opposed inline functions can call function?
a macro text sustitution , such produce more executable code. every time call macro, code inserted (well, not necessarily, macro empty... in principle).
inline functions, on other hand, may work same macros, might not inlined @ all.
in general, inline
keyword rather weak hint requirement anyway, compilers nowadays judiciously inline functions (or abstain doing so) based on heuristics, number of pseudo-instructions.
inline functions may cause compiler not inline function @ all, or inline couple of times , call non-inined in addition.
surprisingly, not inlining may faster inlining, since reduces overall code size , number of cache , tlb misses.
Comments
Post a Comment