get_urlmatch: avoid useless strbuf write
authorJeff King <peff@peff.net>
Thu, 20 Aug 2015 14:49:45 +0000 (10:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Aug 2015 20:16:50 +0000 (13:16 -0700)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
index 04befce5b7609f5962ab250dfdac9b63d360cc7b..71acc4414352e8d097447993937db96a1cc6efaa 100644 (file)
@@ -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);