git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC v1 0/5] add strbuf_set operations
@ 2014-06-09  8:36 Jeremiah Mahler
  2014-06-09  8:36 ` [PATCH/RFC v1 1/5] " Jeremiah Mahler
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Jeremiah Mahler @ 2014-06-09  8:36 UTC (permalink / raw)
  To: git; +Cc: Jeremiah Mahler

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-06-09 22:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).