From 39dbd49b4138b6cdc9fb73e317d4e9f06df0c5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 17 Jun 2023 22:42:26 +0200 Subject: replace strbuf_expand_dict_cb() with strbuf_expand_step() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid the overhead of setting up a dictionary and passing it via strbuf_expand() to strbuf_expand_dict_cb() by using strbuf_expand_step() in a loop instead. It requires explicit handling of %% and unrecognized placeholders, but is more direct and simpler overall, and expands only on demand. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- strbuf.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index a90b597da1..972366b410 100644 --- a/strbuf.c +++ b/strbuf.c @@ -468,22 +468,6 @@ size_t strbuf_expand_literal_cb(struct strbuf *sb, return 0; } -size_t strbuf_expand_dict_cb(struct strbuf *sb, const char *placeholder, - void *context) -{ - struct strbuf_expand_dict_entry *e = context; - size_t len; - - for (; e->placeholder && (len = strlen(e->placeholder)); e++) { - if (!strncmp(placeholder, e->placeholder, len)) { - if (e->value) - strbuf_addstr(sb, e->value); - return len; - } - } - return 0; -} - void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src) { size_t i, len = src->len; -- cgit v1.2.3