Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Monday, September 10, 2007 - 1:49 pm

On Sun, 09 Sep 2007 02:37:18 +0200, Pierre Habouzit wrote:



 Some string APIs don't store the size, some include the bytes in the
"struct" itself using the struct hack, in C. For instance ustr uses 
3 bytes more than strdup(), by default, for "small" strings[1] -- which
includes a size, length, reference counting and a "memory failure occured"
error.

 On the other extreme, C++ strings or Vstr take up much more than
12/24[2] bytes (because they are designed to be used differently) and
strbuf itself takes up 16/20[2] bytes.

 Note that I'm not saying you shouldn't use a decent string API, quite
the opposite, but assuming that "whatever is embedded in the language"
is good enough for all purposes is far from reality.


[1] 1-255 bytes is "small", for obvious reasons you need one more byte
after that (note that "", 0 byte strings, don't take any bytes to store
with ustr).

[2] 32bit/64bit sizes

-- 
James Antill -- james@and.org
C String APIs use too much memory? ustr: length, ref count, size and
read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings
http://www.and.org/ustr/

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., James Antill, (Mon Sep 10, 1:49 pm)