git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremiah Mahler <jmmahler@gmail.com>
To: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3 1/2] add strbuf_set operations
Date: Thu, 12 Jun 2014 01:22:18 -0700	[thread overview]
Message-ID: <20140612082218.GA5419@hudson.localdomain> (raw)
In-Reply-To: <539960B8.1080709@virtuell-zuhause.de>

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_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 being performed.
> > 
> >   strbuf_reset(buf);
> >   strbuf_add(buf, data1, len1);
> >   strbuf_add(buf, data2, len2);
> >   strbuf_add(buf, data3, len3);
> > 
> > However, in other cases, it can be confusing and is not very concise.
> > 
> >   strbuf_reset(buf);
> >   strbuf_add(buf, default, len1);
> > 
> >   if (cond1) {
> >     strbuf_reset(buf);
> >     strbuf_add(buf, data2, len2);
> >   }
> > 
> >   if (cond2) {
> >     strbuf_reset(buf);
> >     strbuf_add(buf, data3, len3);
> >   }
> > 
> > Add strbuf_set operations so that it can be re-written in a clear and
> > concise way.
> > 
> >   strbuf_set(buf, default len1);
> very minor nit: missing comma between default and len1.

I can't believe I missed that.  Good catch ;-)

-- 
Jeremiah Mahler
jmmahler@gmail.com
http://github.com/jmahler

  reply	other threads:[~2014-06-12  8:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12  7:29 [PATCH v3 0/2] add strbuf_set operations Jeremiah Mahler
2014-06-12  7:29 ` [PATCH v3 1/2] " Jeremiah Mahler
2014-06-12  8:11   ` Thomas Braun
2014-06-12  8:22     ` Jeremiah Mahler [this message]
2014-06-12 18:51       ` Junio C Hamano
2014-06-12 19:36         ` Jeremiah Mahler
2014-06-12 21:18           ` Eric Sunshine
2014-06-12 23:14             ` Jeremiah Mahler
2014-06-12 18:50   ` Junio C Hamano
2014-06-12 19:31     ` Jeremiah Mahler
2014-06-12 21:48       ` Eric Sunshine
2014-06-12 23:46         ` Jeremiah Mahler
2014-06-13  7:15           ` Jeff King
2014-06-14  4:49             ` Jeremiah Mahler
2014-06-12  7:29 ` [PATCH v3 2/2] builtin/remote: improve readability via strbuf_set() Jeremiah Mahler
2014-06-12  8:19   ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140612082218.GA5419@hudson.localdomain \
    --to=jmmahler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=thomas.braun@virtuell-zuhause.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).