From: Jeff King Date: Tue, 14 Jul 2026 21:49:41 GMT Subject: Re: [PATCH] strbuf: avoid redundant reset in strbuf_getwholeline() Message-ID: <20260714214941.GB4095533@coredump.intra.peff.net> In-Reply-To: On Tue, Jul 14, 2026 at 10:45:59AM +0200, René Scharfe wrote: > The HAVE_GETDELIM variant of strbuf_getwholeline() calls strbuf_reset() > on the strbuf before handing it over to getdelim(3). This is > unnecessary: > > - getdelim(3) doesn't care whether the old buffer contents is > NUL-terminated and has no access to ->len, > - on success getdelim(3) NUL-terminates the buffer and we set ->len, > - on error we either call strbuf_init() or strbuf_reset(). > > Remove the superfluous preparatory call. Good catch. In the original version of strbuf_getwholeline() we were missing that reset on error, which is why this was included. I think it became redundant in b70904306f (strbuf_getwholeline: NUL-terminate getdelim buffer on error, 2016-03-05). -Peff