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
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jun 22, 2008, 22:20 UTC
Message-ID
<vpqej6p9ko2.fsf@bauges.imag.fr>
In-Reply-To
<alpine.LFD.1.10.0806221159140.2926@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 11 quoted lines
> -static inline char* xstrdup(const char *str)
> -{
> -	char *ret = strdup(str);
> -	if (!ret) {
> -		release_pack_memory(strlen(str) + 1, -1);
> -		ret = strdup(str);
> -		if (!ret)
> -			die("Out of memory, strdup failed");
> -	}
> -	return ret;
> -}
Wouldn't it be better to split that kind of function into two parts:
- inline the short common case
- put the special case apart
like
static inline char* xstrdup(const char *str)
{
	char *ret = strdup(str);
	if (!ret)
		return xstrdup_failed(str);
	else
		return ret;
}
(with xstrdup_failed not being inline.)
?
-- 
Matthieu
Previous: Christian MICHONNext: Linus Torvalds
Message 6 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.