Inlining user code eliminates the overhead of the function call and linkage, and exposes the function's code to the optimizer, resulting in faster code performance. Inlining produces the best results when the overhead for the function is significant; for example, when functions are called within nested loops.
The best candidates for inlining are small functions that are called often.
To improve performance further:
Drawbacks of Inlining
Inlining user code usually results in a larger executable module.
Because of the extra optimizations that can be performed, the
difference in size may be less than the size of the function
multiplied by the number of calls.
Inlining can also result in slower program performance, especially if you use auto-inlining. Because auto-inlining looks only at the number of ACUs for a function, the functions that are inlined are not always the best candidates for inlining. As much as possible, use the _Inline or inline keyword to choose the functions to be inlined.
When you use inlining, you need more stack space. When a function is called, its local storage is allocated at the time of the call and freed when it returns to the calling function. If that same function is inlined, its storage is allocated when the function that calls it is entered, and is not freed until that calling function ends. Ensure that you have enough stack space for the local storage of the inlined functions, in order to avoid a stack overflow.