Re: Shrink the git binary a bit by avoiding unnecessary inline functions
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Jun 22, 2008, 22:40 UTC
- Message-ID
- <alpine.LFD.1.10.0806221532560.2926@woody.linux-foundation.org>
- In-Reply-To
- <vpqej6p9ko2.fsf@bauges.imag.fr>
On Mon, 23 Jun 2008, Matthieu Moy wrote:
Show 5 quoted lines
> > Wouldn't it be better to split that kind of function into two parts: > > - inline the short common case > - put the special case apart
It's almost certainly not worth it. These things really aren't big optimization wins, and the *big* wins from doing inlines are if it allows the call-site to do more optimizations (eg conditionals or calculations that just go away if inlined with constant arguments, for example), or if the lack of any function call at all allows the caller to do better register allocation around it.
Since these inlines contain a real call regardless, the second case never happens.
The first case can happen with things like "strlen()" being optimized away for constant-sized arguments, but for the one user where that was (xstrdup()) it really wasn't an issue. And while a constant size argument to "xmalloc()" is not unlikely, and would allow the compiler to optimize the
if (!ret && !size) ret = malloc(1);
away statically as an inline, it's really not a big win.
Linus