Super quick answer: Yes, maybe.
Quick answer: Yes, but usually itβs not enough for you to take care, and sometimes not at all.
The complete answer: if all the functions are in the same translation system, and the compiler is not sucked, the additional level of the function call will simply be optimized, and it will be zero . top performance. Otherwise, if you are making external function calls, expect a small but non-zero performance. In most cases, this does not matter, but in functions that are super-short, where each cycle is counted, this can make your program twice as slow or worse. Some of the worst examples are:
- A function of type
getc , which simply pulls the next byte from the buffer, advances the position and returns (in the general case, when the buffer is not empty). - A function that promotes a state machine through a trivial operation and returns, for example, processes one byte of the UTF-8 character.
- Lock / sync items. This is a bit of a special case, because actual access to atomic memory should dominate the execution time, making the overhead seem insignificant. But if your intended use case is only to hold locks for one trivial operation (for example,
lock(); a++; unlock(); ), then even a small amount of added time with locking can have serious consequences for competing characteristics if blocking is very contrary.
Finally, the answer is βwhat should you doβ: write your code in the most natural way until testing / measurement shows you performance problems. Only then should you consider removing your code for performance.
source share