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).
Posted Feb 23, 2007 14:03 UTC (Fri)
by samtherecordman (guest, #43207)
[Link]
int small_function(int val)
void main()
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.
In the case where you want to a function to be inline in some cases and not others what about:moving inline keyword from callee to caller
{
return val+1;
}
{
int i = 0;
for(i = 0; i < 10000; i++)
{
small_function() __inline__
}
}