INLINE FUNCTIONS DON'T USE STACK. THEREFORE, EXECUTION TIME IS LESS.HOWEVER, THE STATEMENTS IN THE FUNCTION ARE SUBSTITUTED WHENEVER THE FUNCTION IS CALLED.INLINE FUNCTIONS ARE ALWAYS SHORT.

INLINE FUNCTIONS DON'T USE STACK. THEREFORE, EXECUTION TIME IS LESS.HOWEVER, THE STATEMENTS IN THE FUNCTION ARE SUBSTITUTED WHENEVER THE FUNCTION IS CALLED.INLINE FUNCTIONS ARE ALWAYS SHORT.

Many assumptions there, tamilselvi, and none of them are safe: http://www.gotw.ca/gotw/033.htm

"STATEMENTS IN THE FUNCTION ARE SUBSTITUTED WHENEVER THE FUNCTION IS CALLED."

This is very true, but the only thing on the stack would be automatic variables in the function. The function itself is turned into machine (or intermediate) code when compiled. It can expand the size of the translation unit's object code significantly, but you eliminate the overhead of a function call, including all the stack pushing and popping that goes on. In any case, these functions can be very large, but for best effect, keep them as small as possible. This is why in C++ classes, inline methods are generally small getter/setter or other trivial functions. Others should be implemented in the source file instead of the class definition header file. This is a trade off between speed and size. If the function is large and/or complex, then the function call overhead is probably only a small part of the total time taken to execute it.

One final thing, statements are inserted into the function when compiled, not when it is called. :-)

Edited 2 Years Ago by rubberman

This article has been dead for over six months. Start a new discussion instead.