How judicious ought one be when inlining small methods.
I once read that in general, most compiles will only inline 'one'
level.
IE: if all the following methods were declared/defined as inline in
their respective classes, can I expect the compiler to try and inline
them all?
obj.GetSize()
{
a.GetLen()
{
b.GetHead();
{
c.CreateIterato r();
I'm sorry if this is hard to understand visually. I'm just trying to
depict they the code would be logically 'copied' and embedded at
successive levels of the call stack.
<offtopic>
If I were more adept at GDB, or Visual Studio - I'd prefer to look at
the resulting ASSEMBLY to see for myself what it did. Maybe I can
execute the app in DEBUG mode and open the disassembly window - but
would that jump to the method declarations? I'm not as facile at
ASSEMBLY of the debugger as I wish. Suggestions or general rules?
</offtopic>
Contextually, I have written a wrapper class for a library that is
essentially composed of 'pass through' calls.
IE: I've created a C++ class interface over a set of C library calls.
struct GuiHelper
{
inline void SetWindowPos(in t, int, int, int)
{
::SetWindowPos( ...);
}
}
And I'm worried (per that article I seem to remember seeing) that if I
use any of these methods in my other functions - that I will have used
up my ONE inline call per function stack. In other word, if I use
these methods in other, inline calls, when will the compiler be apt to
eventually quit inlining things?
Quantitatively then, is judicious inlining important? or can I willy
nilly declare/define all very small tight methods as inline and be
confident that several small inlined methods calling each other will
likely, all be inlined.
--note: this also goes for Setters and Getters. I'm afraid of
supplying getX or getY methods for fear that anywhere they will be
used - they will use up the ONE level of inlining the compiler will
create - and consequently, might not be the best method of the stack
to have inlined.
Thanks in advance for any insight,
-Luther
I once read that in general, most compiles will only inline 'one'
level.
IE: if all the following methods were declared/defined as inline in
their respective classes, can I expect the compiler to try and inline
them all?
obj.GetSize()
{
a.GetLen()
{
b.GetHead();
{
c.CreateIterato r();
I'm sorry if this is hard to understand visually. I'm just trying to
depict they the code would be logically 'copied' and embedded at
successive levels of the call stack.
<offtopic>
If I were more adept at GDB, or Visual Studio - I'd prefer to look at
the resulting ASSEMBLY to see for myself what it did. Maybe I can
execute the app in DEBUG mode and open the disassembly window - but
would that jump to the method declarations? I'm not as facile at
ASSEMBLY of the debugger as I wish. Suggestions or general rules?
</offtopic>
Contextually, I have written a wrapper class for a library that is
essentially composed of 'pass through' calls.
IE: I've created a C++ class interface over a set of C library calls.
struct GuiHelper
{
inline void SetWindowPos(in t, int, int, int)
{
::SetWindowPos( ...);
}
}
And I'm worried (per that article I seem to remember seeing) that if I
use any of these methods in my other functions - that I will have used
up my ONE inline call per function stack. In other word, if I use
these methods in other, inline calls, when will the compiler be apt to
eventually quit inlining things?
Quantitatively then, is judicious inlining important? or can I willy
nilly declare/define all very small tight methods as inline and be
confident that several small inlined methods calling each other will
likely, all be inlined.
--note: this also goes for Setters and Getters. I'm afraid of
supplying getX or getY methods for fear that anywhere they will be
used - they will use up the ONE level of inlining the compiler will
create - and consequently, might not be the best method of the stack
to have inlined.
Thanks in advance for any insight,
-Luther
Comment