Let’s say I have two functions:
void foo() {
// A big function
}
// This is a wrapper to foo
inline void bar() {
// couple of lines -- simple ones. I promise!
foo();
}
I’m aware that compiler is the one that eventually decides whether or not to inline a function. What i’m wondering is when it comes to wrappers (that call other functions), how deep does the compiler do the analysis?
Does it stop inside bar() and just copies whatever is inside wherever bar() is called or does it also look into foo()? How is this different if foo() is inside a pre-compiled library that is dynamically linked to bar()?
The only way to know for sure is to check the disassembly.
In general I never worry about such micro-optimizations because I trust the compiler to make the right choice in inlining decisions. Only if profiling shows me that function calls are causing significant overhead would I attempt to change the compiler’s choice.