From: Christian Couder Date: Tue, 27 Feb 2024 10:07:45 GMT Subject: Re: [Outreachy][PATCH 1/2] strbuf: introduce strbuf_addstrings() to repeatedly add a string Message-ID: In-Reply-To: On Mon, Feb 26, 2024 at 7:10 PM Junio C Hamano wrote: > > Christian Couder 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.