From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 0/5] replace strbuf_expand()
Date: Sat, 17 Jun 2023 22:37:30 +0200 [thread overview]
Message-ID: <767baa64-20a6-daf2-d34b-d81f72363749@web.de> (raw)
strbuf_expand() is used to interpolate placeholders that start with a
percent sign (%) in strings. It invokes a callback function to handle
those placeholders, expands "%%" to "%" itself and copies unrecognized
placeholders verbatim. Context info for the callback needs to be
passed in via a void pointer, e.g. to a custom struct.
There is a better, simpler way: Use a loop to iterate over placeholders
and access variables directly, without the need to take a detour through
a context struct. This series converts the callers of strbuf_expand()
to use the new helper strbuf_expand_step(), removing the overhead that
comes with using a callback.
pretty: factor out expand_separator()
strbuf: factor out strbuf_expand_step()
replace strbuf_expand_dict_cb() with strbuf_expand_step()
replace strbuf_expand() with strbuf_expand_step()
strbuf: simplify strbuf_expand_literal_cb()
builtin/branch.c | 13 +-----
builtin/cat-file.c | 35 +++++++--------
builtin/ls-files.c | 109 +++++++++++++++++++--------------------------
builtin/ls-tree.c | 107 +++++++++++++++++---------------------------
convert.c | 22 +++++----
daemon.c | 61 ++++++++-----------------
ll-merge.c | 32 +++++++------
pretty.c | 99 ++++++++++++++++++++++------------------
strbuf.c | 58 +++++-------------------
strbuf.h | 57 ++++--------------------
10 files changed, 228 insertions(+), 365 deletions(-)
--
2.41.0
next reply other threads:[~2023-06-17 20:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-17 20:37 René Scharfe [this message]
2023-06-17 20:40 ` [PATCH 1/5] pretty: factor out expand_separator() René Scharfe
2023-06-17 20:41 ` [PATCH 2/5] strbuf: factor out strbuf_expand_step() René Scharfe
2023-06-19 16:10 ` Taylor Blau
2023-06-20 16:25 ` René Scharfe
2023-06-21 12:26 ` Taylor Blau
2023-06-27 8:26 ` Jeff King
2023-06-27 16:21 ` René Scharfe
2023-06-17 20:42 ` [PATCH 3/5] replace strbuf_expand_dict_cb() with strbuf_expand_step() René Scharfe
2023-06-27 8:29 ` Jeff King
2023-06-27 8:35 ` Jeff King
2023-06-27 16:24 ` René Scharfe
2023-06-17 20:43 ` [PATCH 4/5] replace strbuf_expand() " René Scharfe
2023-06-27 8:54 ` Jeff King
2023-06-27 16:31 ` René Scharfe
2023-06-27 20:19 ` Jeff King
2023-06-17 20:44 ` [PATCH 5/5] strbuf: simplify strbuf_expand_literal_cb() René Scharfe
2023-06-27 8:57 ` Jeff King
2023-06-27 16:32 ` René Scharfe
2023-06-27 20:21 ` Jeff King
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=767baa64-20a6-daf2-d34b-d81f72363749@web.de \
--to=l.s.r@web.de \
--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 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).