What is inlining?

When executing a given piece of code, whenever you call a standard function the execution time is slightly higher than dumping there the code contained into that function. Dumping every time the whole code contained in a function is on the other end unmainteinable because it obviously leads to a whole mess of duplication of code.

Inlining solves the performance and maintainability issue by letting you declare the function as inline (at least in C++), so that when you call that function – instead of having your app jumping around at runtime – the code in the inline function is injected at compile time every time that given function is called.

Downside of this is that – if you inline big functions which you call a lot of times – the size of your program may significantly increase (best practices suggest to do it only on small functions indeed).

Leave a Comment