Jump to content
  • Advertisement

Archived

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

Bullmax

inlining functions... when ?

This topic is 5674 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

When should I use inline functions. I know that the function content execution must be simple and, I think, faster than the function call. Examples: pixel plotting, class accessors & mutators, etc... But do someone have a good and precise way to evaluate if a function fits to be inlined. I''m just annoyed of making modifications to my "supposed to be inlined funtion" and having recompile the whole stuff... If my functions don''t fit to be inlined, I want them to be in a "*.cpp" instead of a "*.h".
/* Bullmax */ ------------- Reality has many forms : good and evil, black and white, yin and yang.

Share this post


Link to post
Share on other sites
Advertisement
This is how I see it. Though it might not be the best way to think of it.
It depends on the function. If it was something like to add a couple of numbers together then you would use an inline, because there wouldn''t be a lot of point jumping for a job so small. If it was a more complex function then you''d probably wouldn''t use inline.

Inline functions are like writting the code in the function where you called it, instead of a jump like a normal function. They are similar to Macros in C.

slip

Share this post


Link to post
Share on other sites
Don''t worry about inlining until your program is complete.

What functions can be inlined and what happens when inlining fails is compiler-dependent - check the documentation.

As a rule of thumb, any kind of loop, recursion or taking the address of the function will inhibit inlining.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!