Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sheepopo39

macrumors 6502
Original poster
Sep 18, 2008
251
0
I just read over inline functions and I understand what it does, but I don't really see how you're gaining anything when you use it, because if you were to call the function (not inline), that code in the function would still be executed like it was in that part of the code. So then, what's the difference? :confused:
 
It's a code size/speed tradeoff; when you inline a function you effectively remove the function call overhead by inserting the code directly into the locations where it is called. In functions which are called often this can result in a significant speed boost. This does cause a potentially significant increase in the code size of the program unless the function is very small. Inlining is one of the things that you are probably best off leaving the compiler to decide unless you really know what you are doing as inlining some functions can actually cause a performance hit instead of a boost.
 
In fact, the compiler is free to ignore the "inline" keyword. Just like it quite likely ignores the "register" keyword.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.