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>
Jeff King committed
Aug 20, 2015 at 10:49 UTC
a92330d21c13cf244d8045f5c9d1df6e63893d58
1 file changed
+1
-4
builtin/config.c
+1
-4
@@ -425,14 +425,11 @@ static int get_urlmatch(const char *var, const char *url)
425
426
for_each_string_list_item(item, &values) {
427
struct urlmatch_current_candidate_value *matched = item->util;
428
- struct strbuf key = STRBUF_INIT;
428
struct strbuf buf = STRBUF_INIT;
429
431
- strbuf_addstr(&key, item->string);
432
- format_config(&buf, key.buf,
430
+ format_config(&buf, item->string,
431
matched->value_is_null ? NULL : matched->value.buf);
432
fwrite(buf.buf, 1, buf.len, stdout);
435
- strbuf_release(&key);
433
strbuf_release(&buf);
434
435
strbuf_release(&matched->value);