[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "inline" overused in .c files?
From: |
Bruno Haible |
Subject: |
Re: "inline" overused in .c files? |
Date: |
Tue, 27 Jul 2010 01:22:07 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Paul,
In some cases, I experienced that a program can be made 5% faster just by
marking selected functions as 'inline'. Good candidates are those which
are only used at one place, and those which are small and where the function
call overhead would be noticeable.
In gnulib, we use 'inline' with moderation.
> this asks the compiler not to warn about unused functions
The absence of this warning when 'static inline' is used is not a problem,
because in this case gcc doesn't emit code for the unused function anyway.
I don't care much whether a .o file built by a compiler that doesn't
understand 'inline' is somewhat bigger, as this affects only few platforms,
like HP-UX. So I don't find your argument against the use of 'inline'
very strong.
But there are two other arguments against too much use of 'inline':
1. It makes debugging harder, at least with many combinations of gcc + gdb.
2. Denoting too many functions 'inline' could lead to not so good compiled
code on x86 with gcc 2,/3.x. (Newer versions of gcc know how to save and
restore a register even inside a function, where there is register
pressure, so the use of 'inline' on large functions is not much of a
problem any more.)
Bruno