From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "René Scharfe" <l.s.r@web.de>, "Git List" <git@vger.kernel.org>
Subject: Re: [PATCH] use strbuf_addbuf() for appending a strbuf to another
Date: Fri, 22 Jul 2016 09:22:19 -0700 [thread overview]
Message-ID: <xmqqr3albq2s.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160721210253.GA4604@sigill.intra.peff.net> (Jeff King's message of "Thu, 21 Jul 2016 17:02:54 -0400")
Jeff King <peff@peff.net> writes:
> I don't think we do. Going back to the original discussion:
>
> http://thread.gmane.org/gmane.comp.version-control.git/136141/focus=136774
>
> it was mostly just "hey, this would fail really confusingly if we ever
> did, so let's make it safe".
>
> The second strbuf_grow() is by definition a noop (which is why 81d2cae
> works at all), but we do pay the size-computation cost.
Both true. If the second one is not a noop, nothing is fixed by
81d2cae at all, but it is subtle.
René's update makes it far easier to understand what is going on.
>> -- >8 --
>> Subject: strbuf: avoid calling strbuf_grow() twice in strbuf_addbuf()
>>
>> Implement strbuf_addbuf() as a normal function in order to avoid calling
>> strbuf_grow() twice, with the second callinside strbud_add() being a
>> no-op. This is slightly faster and also reduces the text size a bit.
>
> Seems reasonable. IMHO the main advantage is that one does not have to
> reason about the double strbuf_grow() (i.e., that the strbuf_add() is
> safe because we know its grow is a noop).
>
> -Peff
prev parent reply other threads:[~2016-07-22 16:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 18:36 [PATCH] use strbuf_addbuf() for appending a strbuf to another René Scharfe
2016-07-20 13:20 ` Jeff King
2016-07-21 16:46 ` René Scharfe
2016-07-21 21:02 ` Jeff King
2016-07-22 16:22 ` Junio C Hamano [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr3albq2s.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).