Maxim Dounin mdounin at
Mon Feb 17 14:01:51 UTC 2014


On Fri, Feb 14, 2014 at 04:59:26PM -0500, atarob wrote:

> Looking through the codebase, I see a lot of very short helper like
> functions that are defined in .c files with prototypes in .h files. This
> means that the compiler cannot inline them outside of that .c file. Am I
> wrong?  How is that not a performance hit?

In no particular order:

- As already pointed out, smart enough compilers can inline 
  whatever they want.

- Adding all functions to .h files results in unmanagable code, so 
  there should be a bar somewhere.

- In many cases inlining may actually be a bad idea even from 
  performance point of view, see, e.g., [1].

- If inlining is considired to be beneficial, in most 
  cases nginx uses macros rather than inline functions, see, e.g., 

If you think there are functions which needs be be made 
inlineable - feel free to suggest.


Maxim Dounin

More information about the nginx mailing list