git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Matthieu Moy
Message 7 of 7 in “Shrink the git binary a bit by avoiding unnecessary inline functions”
  1. Linus TorvaldsJun 22, 2008
  2. Christian MICHONJun 22, 2008
  3. Christian MICHONJun 23, 2008
  4. Linus TorvaldsJun 23, 2008
  5. Christian MICHONJun 23, 2008
  6. Matthieu MoyJun 22, 2008
  7. Linus TorvaldsJun 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.