From: Jeremiah Mahler <jmmahler@gmail.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC v1 0/5] add strbuf_set operations
Date: Mon, 9 Jun 2014 15:06:41 -0700 [thread overview]
Message-ID: <20140609220641.GC18783@hudson.localdomain> (raw)
In-Reply-To: <CACsJy8D_eM9OtH=6Z_F0P7GZpqmAdSCEnBjCr_gniZr649P1uw@mail.gmail.com>
Duy,
On Mon, Jun 09, 2014 at 05:39:12PM +0700, Duy Nguyen wrote:
> On Mon, Jun 9, 2014 at 3:36 PM, Jeremiah Mahler <jmmahler@gmail.com> wrote:
> > Currently, the data in a strbuf is modified using add operations. To
> > set the buffer to some data a reset must be performed before an add.
> >
> > strbuf_reset(buf);
> > strbuf_add(buf, cb.buf.buf, cb.buf.len);
> >
> > And this is a common sequence of operations with 70 occurrences found in
> > the current source code. This includes all the different variations
> > (add, addf, addstr, addbuf, addch).
> >
> > FILES=`find ./ -name '*.c'`
> > CNT=$(pcregrep -M "strbuf_reset.*\n.*strbuf_add" $FILES | wc -l)
>
> Hmm.. I wonder if git-grep could do this.. There's pcre support but I
> never tried.
>
Not sure if git-grep does this. The multi-line (-M) support was the
thing I needed.
> > CNT=$(echo "$CNT / 2" | bc)
> > echo $CNT
> > 70
>
> The change in this series looks nice. There's another pattern, save
> strbuf length, then strbuf_setlen() at the beginning or the end of a
> loop. But I think it's less often.
A quick look did not see any obvious patterns for this. I think you are
right, there may be fewer cases.
> --
> Duy
--
Jeremiah Mahler
jmmahler@gmail.com
http://github.com/jmahler
prev parent reply other threads:[~2014-06-09 22:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-09 8:36 [PATCH/RFC v1 0/5] add strbuf_set operations Jeremiah Mahler
2014-06-09 8:36 ` [PATCH/RFC v1 1/5] " Jeremiah Mahler
2014-06-09 8:36 ` [PATCH/RFC v1 2/5] add strbuf_set operations documentation Jeremiah Mahler
2014-06-09 9:53 ` Eric Sunshine
2014-06-09 21:49 ` Jeremiah Mahler
2014-06-09 8:36 ` [PATCH/RFC v1 3/5] sha1_name.c: cleanup using strbuf_set operations Jeremiah Mahler
2014-06-09 8:36 ` [PATCH/RFC v1 4/5] fast-import.c: " Jeremiah Mahler
2014-06-09 10:12 ` Eric Sunshine
2014-06-09 22:00 ` Jeremiah Mahler
2014-06-09 8:36 ` [PATCH/RFC v1 5/5] builtin/remote.c: " Jeremiah Mahler
2014-06-09 10:39 ` [PATCH/RFC v1 0/5] add " Duy Nguyen
2014-06-09 22:06 ` Jeremiah Mahler [this message]
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=20140609220641.GC18783@hudson.localdomain \
--to=jmmahler@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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).