diff options
author | Jeff King <peff@peff.net> | 2015-04-16 11:58:54 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-16 18:15:05 +0300 |
commit | f80c153bea4e0ea86f5b6d32e77df0b69501ee18 (patch) | |
tree | cc4486dc531f676cf884dee2bb962092b840a4a4 /config.mak.uname | |
parent | fec501dae8bf6c8fdcd4124c94f37c4cbc26ba29 (diff) |
strbuf_getwholeline: avoid calling strbuf_grow
As with the recent speedup to strbuf_addch, we can avoid
calling strbuf_grow() in a tight loop of single-character
adds by instead checking strbuf_avail.
Note that we would instead call strbuf_addch directly here,
but it does more work than necessary: it will NUL-terminate
the result for each character read. Instead, in this loop we
read the characters one by one and then add the terminator
manually at the end.
Running "git rev-parse refs/heads/does-not-exist" on a repo
with an extremely large (1.6GB) packed-refs file went from
(best-of-5):
real 0m10.948s
user 0m10.548s
sys 0m0.412s
to:
real 0m8.601s
user 0m8.084s
sys 0m0.524s
for a wall-clock speedup of 21%.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.mak.uname')
0 files changed, 0 insertions, 0 deletions