I have the following class defined in a foo.h
header file
class Foo {
public:
inline int Method();
};
inline int Foo::Method() { // Imple
2. How typically the removal of the inline keyword affect the performance (practically all my methods are inlined)?
The inline
keyword tells the compiler to take the implementation code of that function and put it in place of the function call. This reduces the number of function calls on the stack and if used correctly, can improve the performance of your program.
The inline
keyword should only be used with small functions. Get and Set functions are good examples. They set the value of one variable or return the value of one variable.
If you make a function with a lot of code inline
, it can increase the size of your code by a lot (depending on the size of the function code and how many times that function is used) and actually DECREASE the performance of your program.