From: Eric Sunshine Date: Wed, 03 Dec 2014 00:11:44 GMT Subject: Re: [PATCH 1/3] tree.c: update read_tree_recursive callback to pass strbuf as base Message-ID: In-Reply-To: On Tue, Dec 2, 2014 at 7:11 AM, Duy Nguyen wrote: > On Tue, Dec 2, 2014 at 2:32 AM, Junio C Hamano wrote: >> Nguyễn Thái Ngọc Duy writes: >> >>> This allows the callback to use 'base' as a temporary buffer to >>> quickly assemble full path "without" extra allocation. The callback >>> has to restore it afterwards of course. >> >> Hmph, what's the quote around 'without' doing there? > > because it's only true if you haven't used up all preallocated space > in strbuf. If someone passes an empty strbuf, then underneath strbuf > may do a few realloc until the buffer is large enough. Would it be easier to understand if written like this? This allows the callback to use 'base' as a temporary buffer to quickly assemble full path, thus avoiding allocation/deallocation for each iteration step.