Effective C++ Ed. 3rd: Item 30. Understand the ins and outs of inlining

  • Inline functions prevent the cost of function call. However, excessive overzealous inlining leads to code bloat, resulting in addition paging, reduced cache hit rate etc.
  • Implicit inline request: when defining a function inside a class.
  • Explicit inline request: when preceding function's definition with inline keyword.
  • If f is a library function whose definition is subject to change in future, It should be linked at run-time(instead of making it inline). This way the changes will remain completely transparent to clients.
  • Most debuggers have problems with inlining. So use inline for small functions only.
  • Compiler inline some code in contructors and destructors. If they look empty or small, they may not be so.
prev | next 
Cheers and try hosting at Linode.

    No comments:

    Post a Comment