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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
f225987753
commit
a92330d21c
|
@ -425,14 +425,11 @@ static int get_urlmatch(const char *var, const char *url)
|
||||||
|
|
||||||
for_each_string_list_item(item, &values) {
|
for_each_string_list_item(item, &values) {
|
||||||
struct urlmatch_current_candidate_value *matched = item->util;
|
struct urlmatch_current_candidate_value *matched = item->util;
|
||||||
struct strbuf key = STRBUF_INIT;
|
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
|
||||||
strbuf_addstr(&key, item->string);
|
format_config(&buf, item->string,
|
||||||
format_config(&buf, key.buf,
|
|
||||||
matched->value_is_null ? NULL : matched->value.buf);
|
matched->value_is_null ? NULL : matched->value.buf);
|
||||||
fwrite(buf.buf, 1, buf.len, stdout);
|
fwrite(buf.buf, 1, buf.len, stdout);
|
||||||
strbuf_release(&key);
|
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
|
|
||||||
strbuf_release(&matched->value);
|
strbuf_release(&matched->value);
|
||||||
|
|
Loading…
Reference in New Issue