diff options
author | Jeff King <peff@peff.net> | 2018-08-14 14:20:22 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-14 12:29:54 -0700 |
commit | 79ed0a5e2627a0e1eab0448e6f32d781e80bfafa (patch) | |
tree | 9f6c093dfb279d45c9c8da9b914e6fa2851a1219 /advice.h | |
parent | cat-file: split batch "buf" into two variables (diff) | |
download | tgif-79ed0a5e2627a0e1eab0448e6f32d781e80bfafa.tar.xz |
cat-file: use a single strbuf for all output
When we're in batch mode, we end up in batch_object_write()
for each object, which allocates its own strbuf for each
call. Instead, we can provide a single "scratch" buffer that
gets reused for each output. When running:
git cat-file --batch-all-objects --batch-check='%(objectname)'
on git.git, my best-of-five time drops from:
real 0m0.171s
user 0m0.159s
sys 0m0.012s
to:
real 0m0.133s
user 0m0.121s
sys 0m0.012s
Note that we could do this just by putting the "scratch"
pointer into "struct expand_data", but I chose instead to
add an extra parameter to the callstack. That's more
verbose, but it makes it a bit more obvious what is going
on, which in turn makes it easy to see where we need to be
releasing the string in the caller (right after the loop
which uses it in each case).
Based-on-a-patch-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'advice.h')
0 files changed, 0 insertions, 0 deletions