User: Password:
|
|
Subscribe / Log in / New account

Drawing the line on inline

Drawing the line on inline

Posted Jan 16, 2006 21:34 UTC (Mon) by roc (subscriber, #30627)
Parent article: Drawing the line on inline

One thing that's missing from this discussion is that in many cases you want some invocations of function F to be inlined and other invocations of the same function to NOT be inlined. In particular invocations of F in hot paths should be inlined and invocations in cold, infrequently executed code should not (unless inlining F is actually smaller than a regular function call to F). You can't get this effect just by twiddling 'inline' declarations in the source, so the compiler (perhaps assisted with profile information) can actually do a better job then you can at the source level (unless you go around inline the code by hand in the source code, which is madness).


(Log in to post comments)

moving inline keyword from callee to caller

Posted Feb 23, 2007 14:03 UTC (Fri) by samtherecordman (guest, #43207) [Link]

In the case where you want to a function to be inline in some cases and not others what about:

int small_function(int val)
{
return val+1;
}

void main()
{
int i = 0;

for(i = 0; i < 10000; i++)
{
small_function() __inline__
}
}

This would support selective inlining, and also helps the programmer who is new to the code visualize what is going on - you don't need to see the definiton of small_function() to see that the function will be inlined.


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds