Summary

This chapter dealt with different techniques of calling and using functions.

One way to avoid function overhead for a certain type of function is to use macros. Although the use of macros can certainly speed up code that uses small functions repetitiously, you should be wary of using them because of the possibility of unexpected behavior. Most often there are other ways to solve the problems. Use macros only when you feel you really have to.

Another way of eliminating function call overhead is to inline functions. Use inlining only for short functions which are called frequently or are part of a time-critical piece of code. Sadly, however, for practically all compilers the inlining of functions is merely a suggestion made by the programmer. ...

Get C++ Footprint and Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.