Re: [PATCH 3/5] progress: assemble percentage and counters in a strbuf before printing
- Date: Wed, 27 Mar 2019 11:24:51 +0100
- From: SZEDER Gábor <szeder.dev@xxxxxxxxx>
- Subject: Re: [PATCH 3/5] progress: assemble percentage and counters in a strbuf before printing
On Tue, Mar 26, 2019 at 01:45:41AM -0400, Jeff King wrote:
> On Mon, Mar 25, 2019 at 11:38:42AM +0100, SZEDER Gábor wrote:
> > The following patches in this series want to handle the progress bar's
> > title and changing parts (i.e. the counter and the optional percentage
> > and throughput combined) differently.
> > To prepare for those changes assemble the changing parts in a separate
> > strbuf before printing.
> Makes sense. Unlike the previous patch, we're already in the "slow path"
> of the function here, so we don't need to worry about adding an extra
> buffer (though do still think it's worth reusing the same buffer each
> time, as you do here).
The commit message doesn't mention this, but the next patch needs the
length of the previously displayed progress bar to properly clean up
its remnants. Or the length of its changing parts anyway. So I could
either add a 'prev_len' field to 'struct progress', or the whole
strbuf. The strbuf containing the throughput is already stored in
there and reused, so I just followed suit.