Archived

This topic is now archived and is closed to further replies.

What does inline Do....

This topic is 6362 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how do I decide which functions to inline, like inline void myfun(); right now i inlined my vector and matrice + - * operations.. I want to know is there a time where inline is bad.. because I don''t really know what inline does with the EXE.. can someone explain?

Share this post


Link to post
Share on other sites
Inlining a function simply plugs the function code into your code where you called the function (just like a macro, it replaces the function call, with the code). People inline functions in order to get speed, since the stack frame slows down things quite a bit. (If you don''t know what a stack frame is, just keep in mind that it''s slower than an inlined function )


..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
It tends to be inadvisable to inline functions that are big and are called lots of times because it increases the size of the program (or so I read in a book)

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Inline small routines which get called a lot. It will cost you a bit in terms of executable size, but you will save tons of time in branching, returning, and pushing/popping frame status onto the stack...

Share this post


Link to post
Share on other sites
Everything said so far is fine, but remember using inline is a suggestion to the compiler. A variety of things will make the compiler ignore your suggestion. There is a cost/benefit analysis done as part of this determination. Recursive functions will not actually be inline. Even with Microsquishies'' _forceinline key word not every function will be inlined.

I''ve always heard (and generally followed) the rule that you don''t inline functions as you design/code. Inline them later when its time for optimization.

Mike Roberts
aka milo
mlbobs@telocity.com

Share this post


Link to post
Share on other sites