What is meant by Inline Function(method) in C++ ?
What is special about Inline Functions in C++?
What is meant by Inline Function(method) in C++ ?c++ code
inline should only be used with very small functions that need to run as fast as possible. The compiler will do extra optimizations on the function as well as potentially copying the code into the callers code to alleviate call and return instructions. This would only be two or three instructions, but a function that is called a million times this will mean a savings of 3 million instructions.
The down side of this is that it will increase the size of your code. Also calling the routine through a function pointer will have unknown results.
The inline keyword in other compliers allows you to place assembly language directly into your c code. This would be device specific, but allows you to bypass any extra overhead the compiler may have introduced when compiling c code. It is probably a better optimization technique than an inline fuction (both combined would be best), but it requires much more technical knowledge.
The inline function is very close to #define macro substitution except it is done on the binary side. The #define macro substitutes the source code and the inline function substitutes the binary instructions.
This sort of optimization should not be performed unless you need it. Write the code first and optimize only the sections that need it and only if you experience performance issues. Optimization is time consuming and makes the code much less readable. Don't optimize up front as the code probably doesn't need it and you would be wasting valuable time that could be spent writing better features.
More Related Questions and Answers ...
The information post by website user , we not guarantee correctness.
Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes
