Will inline functions really speed up my application?

When I made my render functions inline, my performace died. What’s happening?

P.D.: To make a inline function I only have to implement it on the header file, isn’t it?

How big is the function you inlined? If its too big, or too many functions are inlined, then performance can be hurt due to increased cache miss frequency.

> If you’re writing standard C functions,
> though, I’m pretty sure that putting it in
> the header is just going to create a copy
> of the function for every .c that includes
> the header. Better form would be to
> declare it inline in the header, and
> define it inline in the .c file.

If it’s not defined in the header, it will
not get inlined in the code, no matter what.

Providing an implementation inline in the
class adds an implicit “inline” to the
declaration of the function, and the compiler
is free to inline the function on use.

Providing an implementation in the header
but outside the class, with the “inline”
keyword in the declaration, is the same as
providing the definition inline in the class.
The compiler may choose to emit the code
inline at the call site, or emit a reference
to the function and actually emit the code
out of line. The compiler and linker may then
conspire to make sure only one of possibly
many emitted copies actually get into your
binary, OR the compiler may take the easy way
out and mark the inline function emitted out
of line as “compilation unit static” and thus
you end up with one copy per file that uses
the function (which still is probably less
space than one copy per call site, which is
the “intended” behaviour of inlining
functions).

It never ceases to amaze me how many
programmers who don’t know the first things
about things like linkage and scope, even
though these are very basic functions of the
tools they use to practice their art.

utbay histay isay otnay aboutay openglay

cheers