Re: [PATCH 3/4] cat-file: use a single strbuf for all output
- From
Jeff King <peff@peff.net>
- Date
- Aug 14, 2018, 19:39 UTC
- Message-ID
- <20180814193932.GD28452@sigill.intra.peff.net>
- In-Reply-To
- <567deabf-cdd3-c4e3-bb6a-b593c1f87c6e@web.de>
On Tue, Aug 14, 2018 at 09:30:57PM +0200, René Scharfe wrote:
Show 12 quoted lines
> > -static void batch_object_write(const char *obj_name, struct batch_options *opt,
> > +static void batch_object_write(const char *obj_name,
> > + struct strbuf *scratch,
> > + struct batch_options *opt,
> > struct expand_data *data)
> > {
> > - struct strbuf buf = STRBUF_INIT;
>
> We could also avoid passing that buffer around by making it static. I
> shy away from adding static variables because the resulting code won't
> be thread-safe, but that fear might be irrational, especially with
> cat-file.True, I didn't even think of that after your original got me in the mindset of passing the buffer down. It's not too bad to do it this way, and I agree with you that we are better avoiding static variables if we can. Five years ago I might have said the opposite, but we've cleaned up a lot of confusing hidden-static bits in that time. Let's not go in the opposite direction. :)
-Peff