From: Jeff King Date: Thu, 20 Aug 2015 14:49:45 +0000 (-0400) Subject: get_urlmatch: avoid useless strbuf write X-Git-Tag: v2.6.0-rc0~25^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a92330d21c13cf244d8045f5c9d1df6e63893d58 get_urlmatch: avoid useless strbuf write We create a strbuf only to insert a single string, pass the resulting buffer to a function (which does not modify the string), and then free it. We can just pass the original string instead. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/config.c b/builtin/config.c index 04befce5b7..71acc44143 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -425,14 +425,11 @@ static int get_urlmatch(const char *var, const char *url) for_each_string_list_item(item, &values) { struct urlmatch_current_candidate_value *matched = item->util; - struct strbuf key = STRBUF_INIT; struct strbuf buf = STRBUF_INIT; - strbuf_addstr(&key, item->string); - format_config(&buf, key.buf, + format_config(&buf, item->string, matched->value_is_null ? NULL : matched->value.buf); fwrite(buf.buf, 1, buf.len, stdout); - strbuf_release(&key); strbuf_release(&buf); strbuf_release(&matched->value);