Re: [PATCH 2/3] format_config: simplify buffer handling

2015-08-21 Thread Jeff King
On Fri, Aug 21, 2015 at 10:43:58AM -0700, Junio C Hamano wrote: > Junio C Hamano writes: > > > I wonder if we can do this instead > > > > if (!omit_values) { > > - if (show_keys) > > + if (show_keys && value_) > > strbuf_addch(buf, key_delim); > > > >

Re: [PATCH 2/3] format_config: simplify buffer handling

2015-08-21 Thread Junio C Hamano
Junio C Hamano writes: > I wonder if we can do this instead > > if (!omit_values) { > - if (show_keys) > + if (show_keys && value_) > strbuf_addch(buf, key_delim); > > though. That would eliminate the need for rolling back. No we cannot. "con

Re: [PATCH 2/3] format_config: simplify buffer handling

2015-08-21 Thread Junio C Hamano
Jeff King writes: > When formatting a config value into a strbuf, we may end > up stringifying it into a fixed-size buffer using sprintf, > and then copying that buffer into the strbuf. We can > eliminate the middle-man (and drop some calls to sprintf!) > by writing directly to the strbuf. > > Th

Re: [PATCH 2/3] format_config: simplify buffer handling

2015-08-21 Thread SZEDER Gábor
Quoting Jeff King : When formatting a config value into a strbuf, we may end up stringifying it into a fixed-size buffer using sprintf, and then copying that buffer into the strbuf. We can eliminate the middle-man (and drop some calls to sprintf!) by writing directly to the strbuf. The reason

[PATCH 2/3] format_config: simplify buffer handling

2015-08-20 Thread Jeff King
When formatting a config value into a strbuf, we may end up stringifying it into a fixed-size buffer using sprintf, and then copying that buffer into the strbuf. We can eliminate the middle-man (and drop some calls to sprintf!) by writing directly to the strbuf. The reason it was written this way