Re: [Outreachy][PATCH 1/2] strbuf: introduce strbuf_addstrings() to repeatedly add a string
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Feb 27, 2024, 10:07 UTC
- Message-ID
- <CAP8UFD034evNrUHTomPXwbnFx=VG-ZNpwoLZspJK1pCoOjkc6Q@mail.gmail.com>
- In-Reply-To
- <xmqq7cirnlkg.fsf@gitster.g>
On Mon, Feb 26, 2024 at 7:10 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> > Christian Couder <christian.couder@gmail.com> writes: > > > Unfortunately strbuf_add() calls strbuf_grow() itself which is not > > needed as we have already called strbuf_grow() to avoid repeated > > reallocation. > > Why is it unfortunate? If the current allocation is sufficient, it > is a cheap no-op, isn't it (if not, we should make it so)?
Yeah, I agree that we don't need to be extra efficient and calling strbuf_grow() doesn't add much overhead. So let's just use strbuf_add() repeatedly after calling it once.