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

Previous thread: Re: [PATCH 0/3] more threaded delta patches by Martin Koegler on Tuesday, September 11, 2007 - 2:02 am. (1 message)

Next thread: [PATCH] Added post_merge hook, related documentation, and tests. by Josh England on Tuesday, September 11, 2007 - 12:59 pm. (2 messages)
To: <git@...>
Date: Monday, September 10, 2007 - 1:49 pm

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/

-

Previous thread: Re: [PATCH 0/3] more threaded delta patches by Martin Koegler on Tuesday, September 11, 2007 - 2:02 am. (1 message)

Next thread: [PATCH] Added post_merge hook, related documentation, and tests. by Josh England on Tuesday, September 11, 2007 - 12:59 pm. (2 messages)