Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-13 Thread Jeremiah Mahler
Peff, On Fri, Jun 13, 2014 at 03:15:50AM -0400, Jeff King wrote: > On Thu, Jun 12, 2014 at 04:46:37PM -0700, Jeremiah Mahler wrote: > > > > Although strbuf_set() does make the code a bit easier to read > > > when strbufs are repeatedly re-used, re-using a variable for > > > different

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-13 Thread Jeff King
On Thu, Jun 12, 2014 at 04:46:37PM -0700, Jeremiah Mahler wrote: > > Although strbuf_set() does make the code a bit easier to read > > when strbufs are repeatedly re-used, re-using a variable for > > different purposes is generally considered poor programming > > practice. It's lik

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
Eric, On Thu, Jun 12, 2014 at 05:48:52PM -0400, Eric Sunshine wrote: > On Thu, Jun 12, 2014 at 3:31 PM, Jeremiah Mahler wrote: > > On Thu, Jun 12, 2014 at 11:50:41AM -0700, Junio C Hamano wrote: > >> I am on the fence. > >> > >> I have this suspicion that the addition of strbuf_set() would *only*

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
On Thu, Jun 12, 2014 at 05:18:29PM -0400, Eric Sunshine wrote: > On Thu, Jun 12, 2014 at 3:36 PM, Jeremiah Mahler wrote: > > On Thu, Jun 12, 2014 at 11:51:19AM -0700, Junio C Hamano wrote: > >> Jeremiah Mahler writes: > >> > >> > Thomas, > >> > > >> > On Thu, Jun 12, 2014 at 10:11:36AM +0200, Tho

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Eric Sunshine
On Thu, Jun 12, 2014 at 3:31 PM, Jeremiah Mahler wrote: > On Thu, Jun 12, 2014 at 11:50:41AM -0700, Junio C Hamano wrote: >> I am on the fence. >> >> I have this suspicion that the addition of strbuf_set() would *only* >> help when the original written with reset-and-then-add sequence was >> subop

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Eric Sunshine
On Thu, Jun 12, 2014 at 3:36 PM, Jeremiah Mahler wrote: > On Thu, Jun 12, 2014 at 11:51:19AM -0700, Junio C Hamano wrote: >> Jeremiah Mahler writes: >> >> > Thomas, >> > >> > On Thu, Jun 12, 2014 at 10:11:36AM +0200, Thomas Braun wrote: >> >> Am 12.06.2014 09:29, schrieb Jeremiah Mahler: >> >> >

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
Junio, On Thu, Jun 12, 2014 at 11:51:19AM -0700, Junio C Hamano wrote: > Jeremiah Mahler writes: > > > Thomas, > > > > On Thu, Jun 12, 2014 at 10:11:36AM +0200, Thomas Braun wrote: > >> Am 12.06.2014 09:29, schrieb Jeremiah Mahler: > >> > A common use case with strubfs is to set the buffer to a

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
Junio, Comments below... On Thu, Jun 12, 2014 at 11:50:41AM -0700, Junio C Hamano wrote: > Jeremiah Mahler writes: > > > A common use case with strubfs is to set the buffer to a new value. > > This must be done in two steps: a reset followed by an add. > > > > strbuf_reset(buf); > > strbuf_

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Junio C Hamano
Jeremiah Mahler writes: > Thomas, > > On Thu, Jun 12, 2014 at 10:11:36AM +0200, Thomas Braun wrote: >> Am 12.06.2014 09:29, schrieb Jeremiah Mahler: >> > A common use case with strubfs is to set the buffer to a new value. strubfs??? >> > This must be done in two steps: a reset followed by an ad

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Junio C Hamano
Jeremiah Mahler writes: > A common use case with strubfs is to set the buffer to a new value. > This must be done in two steps: a reset followed by an add. > > strbuf_reset(buf); > strbuf_add(buf, new_buf, len); > > In cases where the buffer is being built up in steps, these operations > make

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
Thomas, On Thu, Jun 12, 2014 at 10:11:36AM +0200, Thomas Braun wrote: > Am 12.06.2014 09:29, schrieb Jeremiah Mahler: > > A common use case with strubfs is to set the buffer to a new value. > > This must be done in two steps: a reset followed by an add. > > > > strbuf_reset(buf); > > strbuf_a

Re: [PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Thomas Braun
Am 12.06.2014 09:29, schrieb Jeremiah Mahler: > A common use case with strubfs is to set the buffer to a new value. > This must be done in two steps: a reset followed by an add. > > strbuf_reset(buf); > strbuf_add(buf, new_buf, len); > > In cases where the buffer is being built up in steps, t

[PATCH v3 1/2] add strbuf_set operations

2014-06-12 Thread Jeremiah Mahler
A common use case with strubfs is to set the buffer to a new value. This must be done in two steps: a reset followed by an add. strbuf_reset(buf); strbuf_add(buf, new_buf, len); In cases where the buffer is being built up in steps, these operations make sense and correctly convey what is bein