From: Jeff King <peff@peff.net>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/4] strbuf_split_buf(): use ALLOC_GROW()
Date: Sun, 4 Nov 2012 06:41:01 -0500 [thread overview]
Message-ID: <20121104114101.GA336@sigill.intra.peff.net> (raw)
In-Reply-To: <1352011614-29334-2-git-send-email-mhagger@alum.mit.edu>
On Sun, Nov 04, 2012 at 07:46:51AM +0100, Michael Haggerty wrote:
> Use ALLOC_GROW() rather than inline code to manage memory in
> strbuf_split_buf(). Rename "pos" to "nr" because it better describes
> the use of the variable and it better conforms to the "ALLOC_GROW"
> idiom.
I suspect this was not used originally because ALLOC_GROW relies on
alloc_nr, which does fast growth early on. At (x+16)*3/2, we end up with
24 slots for the first allocation. We are typically splitting 1 or 2
values.
It probably doesn't make a big difference in practice, though, as we're
talking about wasting less than 200 bytes on a 64-bit platform, and we
do not tend to keep large numbers of split lists around.
-Peff
next prev parent reply other threads:[~2012-11-04 11:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-04 6:46 [PATCH 0/4] Simplify and document strbuf_split() functions Michael Haggerty
2012-11-04 6:46 ` [PATCH 1/4] strbuf_split_buf(): use ALLOC_GROW() Michael Haggerty
2012-11-04 11:41 ` Jeff King [this message]
2012-11-06 7:54 ` Michael Haggerty
2012-11-08 16:38 ` Jeff King
2012-11-04 6:46 ` [PATCH 2/4] strbuf_split_buf(): simplify iteration Michael Haggerty
2012-11-04 6:46 ` [PATCH 3/4] strbuf_split*(): rename "delim" parameter to "terminator" Michael Haggerty
2012-11-04 6:46 ` [PATCH 4/4] strbuf_split*(): document functions Michael Haggerty
2012-11-04 11:50 ` [PATCH 0/4] Simplify and document strbuf_split() functions Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121104114101.GA336@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).