git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC v1 0/5] add strbuf_set operations

From
Jeremiah Mahler <jmmahler@gmail.com>
Date
Jun 9, 2014, 08:36 UTC
Message-ID
<cover.1402301815.git.jmmahler@gmail.com>
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
Next: Jeremiah Mahler
Message 1 of 12 in “add strbuf_set operations”
  1. 0/5 add strbuf_set operationsJeremiah Mahler, Jun 9, 2014
  2. 1/5 add strbuf_set operationsJeremiah Mahler, Jun 9, 2014
  3. 2/5 add strbuf_set operations documentationJeremiah Mahler, Jun 9, 2014
  4. Eric SunshineJun 9, 2014
  5. Jeremiah MahlerJun 9, 2014
  6. 3/5 sha1_name.c: cleanup using strbuf_set operationsJeremiah Mahler, Jun 9, 2014
  7. 4/5 fast-import.c: cleanup using strbuf_set operationsJeremiah Mahler, Jun 9, 2014
  8. Eric SunshineJun 9, 2014
  9. Jeremiah MahlerJun 9, 2014
  10. 5/5 builtin/remote.c: cleanup using strbuf_set operationsJeremiah Mahler, Jun 9, 2014
  11. Duy NguyenJun 9, 2014
  12. Jeremiah MahlerJun 9, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.