Thursday, 26 March 2015

Inline functions,inline functions vs normal functions

Inline functions is a function expansion which aims at improving the code performance by reducing run time at the cost of memory.

-a new copy of inlined functions are formed everytime it is called which makes the execution fast
-reduces calling overheads
-inling is done at compile time while macro expansion occurs at pre-processing stage
-best for small functions as a new copy is created every time
-In C++ the member functions of a class, if defined within the class definition, are inlined by default (no need to use the inline keyword); otherwise, the keyword is needed
-used for functions executed frequently
- a normal function is executed by making a call which transfers the control to function defination while in inline functions function call is eliminated & direct function defination is implemented.

inline vs normal functions
-inline functions consume more memory 
-inline functions are faster than normal functions

Inline function expansion is supported by c and c++ but not by JAVA. 


No comments:

Post a Comment