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.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'strbuf.h') diff --git a/strbuf.h b/strbuf.h index a189f12b84..e293117f07 100644 --- a/strbuf.h +++ b/strbuf.h @@ -357,20 +357,6 @@ size_t strbuf_expand_literal_cb(struct strbuf *sb, const char *placeholder, void *context); -/** - * Used as callback for `strbuf_expand()`, expects an array of - * struct strbuf_expand_dict_entry as context, i.e. pairs of - * placeholder and replacement string. The array needs to be - * terminated by an entry with placeholder set to NULL. - */ -struct strbuf_expand_dict_entry { - const char *placeholder; - const char *value; -}; -size_t strbuf_expand_dict_cb(struct strbuf *sb, - const char *placeholder, - void *context); - /** * If the string pointed to by `formatp` contains a percent sign ("%"), * advance it to point to the character following the next one and -- cgit v1.2.3