All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremiah Mahler <jmmahler@gmail.com>
To: git@vger.kernel.org
Cc: Jeremiah Mahler <jmmahler@gmail.com>
Subject: [PATCH/RFC v1 0/5] add strbuf_set operations
Date: Mon,  9 Jun 2014 01:36:24 -0700	[thread overview]
Message-ID: <cover.1402301815.git.jmmahler@gmail.com> (raw)

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)
  CNT=$(echo "$CNT / 2" | bc)
  echo $CNT
  70
    
These patches add strbuf_set operations which allow this common sequence
to be performed in one line instead of two.
    
  strbuf_set(buf, cb.buf.buf, cb.buf.len);

Only the first few files have been converted in this preliminary patch set.

Jeremiah Mahler (5):
  add strbuf_set operations
  add strbuf_set operations documentation
  sha1_name.c: cleanup using strbuf_set operations
  fast-import.c: cleanup using strbuf_set operations
  builtin/remote.c: cleanup using strbuf_set operations

 Documentation/technical/api-strbuf.txt | 18 ++++++++++++
 builtin/remote.c                       | 51 ++++++++++++----------------------
 fast-import.c                          | 19 ++++---------
 sha1_name.c                            | 15 ++++------
 strbuf.c                               | 21 ++++++++++++++
 strbuf.h                               | 14 ++++++++++
 6 files changed, 81 insertions(+), 57 deletions(-)

-- 
2.0.0.573.ged771ce.dirty

             reply	other threads:[~2014-06-09  8:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09  8:36 Jeremiah Mahler [this message]
2014-06-09  8:36 ` [PATCH/RFC v1 1/5] add strbuf_set operations 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

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=cover.1402301815.git.jmmahler@gmail.com \
    --to=jmmahler@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.