From 6f1e2d52797161c7effe4d1388765de3dbd80bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 17 Jun 2023 22:43:17 +0200 Subject: replace strbuf_expand() with strbuf_expand_step() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid the overhead of passing context to a callback function of strbuf_expand() by using strbuf_expand_step() in a loop instead. It requires explicit handling of %% and unrecognized placeholders, but is simpler, more direct and avoids void pointers. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- strbuf.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index 972366b410..c3d1cee616 100644 --- a/strbuf.c +++ b/strbuf.c @@ -427,26 +427,6 @@ int strbuf_expand_step(struct strbuf *sb, const char **formatp) return 1; } -void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, - void *context) -{ - while (strbuf_expand_step(sb, &format)) { - size_t consumed; - - if (*format == '%') { - strbuf_addch(sb, '%'); - format++; - continue; - } - - consumed = fn(sb, format, context); - if (consumed) - format += consumed; - else - strbuf_addch(sb, '%'); - } -} - size_t strbuf_expand_literal_cb(struct strbuf *sb, const char *placeholder, void *context UNUSED) -- cgit v1.2.3