Skip to content

Commit f77bcca

Browse files
peffgitster
authored andcommitted
config: use strbuf_split_str instead of a temporary strbuf
This saves an allocation and copy, and also fixes a minor memory leak. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f1d9e2 commit f77bcca

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

config.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ void git_config_push_parameter(const char *text)
4242
static int git_config_parse_parameter(const char *text,
4343
config_fn_t fn, void *data)
4444
{
45-
struct strbuf tmp = STRBUF_INIT;
4645
struct strbuf **pair;
47-
strbuf_addstr(&tmp, text);
48-
pair = strbuf_split_max(&tmp, '=', 2);
46+
pair = strbuf_split_str(text, '=', 2);
4947
if (!pair[0])
5048
return error("bogus config parameter: %s", text);
5149
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')

0 commit comments

Comments
 (0)