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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -