Re: [PATCH 4/6] strbuf: add an optimized 1-character strbuf_grow

2015-04-05 Thread Jeff King
On Sun, Apr 05, 2015 at 10:13:21PM -0400, Eric Sunshine wrote: - strbuf_grow(sb, 1); + strbuf_grow_ch(sb); strbuf_grow_ch() seems overly special-case. What about instead taking advantage of inline strbuf_avail() to do something like this? if

Re: [PATCH 4/6] strbuf: add an optimized 1-character strbuf_grow

2015-04-05 Thread Eric Sunshine
On Sat, Apr 4, 2015 at 9:11 PM, Jeff King p...@peff.net wrote: We have to call strbuf_grow anytime we are going to add data to a strbuf. In most cases, it's a noop (since we grow the buffer aggressively), and the cost of the function call and size check is dwarfed by the actual buffer

[PATCH 4/6] strbuf: add an optimized 1-character strbuf_grow

2015-04-04 Thread Jeff King
We have to call strbuf_grow anytime we are going to add data to a strbuf. In most cases, it's a noop (since we grow the buffer aggressively), and the cost of the function call and size check is dwarfed by the actual buffer operation. For a tight loop of single-character additions, though, this