Is the GNU C++ compiler ((GCC) 5.2.0) good at "inlining" by itself? -
i'm not asking why or when should use inline
in code.
i use inline
think it's usual (like in get/set functions). read on stack unusual example inline
sounds necessary. i'm not sure i'll recognize such situation in code... mean, until issue...
so wonder if usual cases compiler handles do, maybe better...
the reason why avoid inline
, avoid having implement in headers ... question pop in mind:
is compiler (i consider gcc compiler in question) able inline
function not implemented in header ?
n.b. : don't know if there internal changes inline
in c++14.
without kind of example code, it's hard sure compiler (even code, can pretty darn difficult).
generally speaking, if function small, compiler inline functions have source code available during compilation (and others if enable lto (link time optimisation). if expect able compile function object file , function inlined, have use lto.
a function large , static, called once inlined in cases.
the problem comes when have several calls , function "more tiny in size" - in other words more 3-4 lines long. compiler has balance between inlining , bloating code, , not inlining , cost of calls. difficult balance right. profile-driven optimisation can lot here, in general, compiler right, not @ guaranteed - if in doubt (and it's important), use benchmark of application, , measure whether gets better force inline attribute.
Comments
Post a Comment