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