format_config: simplify buffer handling
commitf2259877531ed2a58ec04aeaeb6beb5183f81f92
authorJeff King <peff@peff.net>
Thu, 20 Aug 2015 14:47:34 +0000 (20 10:47 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Aug 2015 20:16:50 +0000 (20 13:16 -0700)
tree94b345580485a41172af5a2dc6038ee31f36e86a
parent9f1429df179adb7a315616d01c9b237b521a3733
format_config: simplify buffer handling

When formatting a config value into a strbuf, we may end
up stringifying it into a fixed-size buffer using sprintf,
and then copying that buffer into the strbuf. We can
eliminate the middle-man (and drop some calls to sprintf!)
by writing directly to the strbuf.

The reason it was written this way in the first place is
that we need to know before writing the value whether to
insert a delimiter. Instead of delaying the write of the
value, we speculatively write the delimiter, and roll it
back in the single case that cares.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c