Automated inlining for VC++?
Is there a way to tell the compiler to inline wherever it sees it to be useful? I thought it did 开发者_Python百科this by default, but adding a few inline to my game loop functions improved performance by a good 30%.
Thanks
The /Ob option
Note that the compiler can't auto-inline functions across compilation units unless you use Whole Program Optimization (/GL).
Visual C++ will do auto inline expansion if you tell it to, via the /Ob2
switch (but only if optimizations are turned on, e.g., /O2
).
It could be that this was turned off, or perhaps the compiler isn't as aggressive at inlining as you want. In the latter case, use the inline
keyword (which you have done :D).
The compiler will generally inline functions if it will seem to boost performance, however, it might avoid this if you don't enable optimizations (e.g debug mode). If you enable optimizations, it should probably inline for you.
精彩评论