开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜