Skip to content

Commit a92330d

Browse files
peffgitster
authored andcommitted
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>
1 parent f225987 commit a92330d

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

builtin/config.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,11 @@ static int get_urlmatch(const char *var, const char *url)
425425

426426
for_each_string_list_item(item, &values) {
427427
struct urlmatch_current_candidate_value *matched = item->util;
428-
struct strbuf key = STRBUF_INIT;
429428
struct strbuf buf = STRBUF_INIT;
430429

431-
strbuf_addstr(&key, item->string);
432-
format_config(&buf, key.buf,
430+
format_config(&buf, item->string,
433431
matched->value_is_null ? NULL : matched->value.buf);
434432
fwrite(buf.buf, 1, buf.len, stdout);
435-
strbuf_release(&key);
436433
strbuf_release(&buf);
437434

438435
strbuf_release(&matched->value);

0 commit comments

Comments
 (0)