[PATCH 06/10] config: use strbuf_split_str instead of a temporary strbuf
- From
Jeff King <peff@peff.net>
- Date
- Jun 9, 2011, 15:55 UTC
- Message-ID
- <20110609155509.GF25507@sigill.intra.peff.net>
- In-Reply-To
- <20110609155001.GA14969@sigill.intra.peff.net>
This saves an allocation and copy, and also fixes a minor memory leak.
Signed-off-by: Jeff King <peff@peff.net> --- config.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c index 2517b62..189b766 100644 --- a/config.c +++ b/config.c @@ -42,10 +42,8 @@ void git_config_push_parameter(const char *text) static int git_config_parse_parameter(const char *text, config_fn_t fn, void *data) { - struct strbuf tmp = STRBUF_INIT; struct strbuf **pair; - strbuf_addstr(&tmp, text); - pair = strbuf_split_max(&tmp, '=', 2); + pair = strbuf_split_str(text, '=', 2); if (!pair[0]) return error("bogus config parameter: %s", text); if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
-- 1.7.6.rc1.36.g91167