Revision f3badaed5106a16499d0fae31a382f9047b272d7 authored by Jeff King on 11 February 2016, 22:26:18 UTC, committed by Junio C Hamano on 16 March 2016, 17:41:03 UTC
The "struct name_path" data is examined in only two places:
we generate it in process_tree(), and we convert it to a
single string in path_name(). Everyone else just passes it
through to those functions.

We can further note that process_tree() already keeps a
single strbuf with the leading tree path, for use with
tree_entry_interesting().

Instead of building a separate name_path linked list, let's
just use the one we already build in "base". This reduces
the amount of code (especially tricky code in path_name()
which did not check for integer overflows caused by deep
or large pathnames).

It is also more efficient in some instances.  Any time we
were using tree_entry_interesting, we were building up the
strbuf anyway, so this is an immediate and obvious win
there. In cases where we were not, we trade off storing
"pathname/" in a strbuf on the heap for each level of the
path, instead of two pointers and an int on the stack (with
one pointer into the tree object). On a 64-bit system, the
latter is 20 bytes; so if path components are less than that
on average, this has lower peak memory usage.  In practice
it probably doesn't matter either way; we are already
holding in memory all of the tree objects leading up to each
pathname, and for normal-depth pathnames, we are only
talking about hundreds of bytes.

This patch leaves "struct name_path" as a thin wrapper
around the strbuf, to avoid disrupting callbacks. We should
fix them, but leaving it out makes this diff easier to view.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8eee9f9
History
File Mode Size
add.c -rw-r--r-- 12.3 KB
annotate.c -rw-r--r-- 444 bytes
apply.c -rw-r--r-- 119.3 KB
archive.c -rw-r--r-- 3.0 KB
bisect--helper.c -rw-r--r-- 787 bytes
blame.c -rw-r--r-- 74.9 KB
branch.c -rw-r--r-- 28.9 KB
bundle.c -rw-r--r-- 1.9 KB
cat-file.c -rw-r--r-- 10.2 KB
check-attr.c -rw-r--r-- 4.5 KB
check-ignore.c -rw-r--r-- 4.9 KB
check-mailmap.c -rw-r--r-- 1.6 KB
check-ref-format.c -rw-r--r-- 2.1 KB
checkout-index.c -rw-r--r-- 7.0 KB
checkout.c -rw-r--r-- 34.4 KB
clean.c -rw-r--r-- 23.9 KB
clone.c -rw-r--r-- 27.3 KB
column.c -rw-r--r-- 1.9 KB
commit-tree.c -rw-r--r-- 3.1 KB
commit.c -rw-r--r-- 52.3 KB
config.c -rw-r--r-- 19.3 KB
count-objects.c -rw-r--r-- 3.3 KB
credential.c -rw-r--r-- 663 bytes
describe.c -rw-r--r-- 12.1 KB
diff-files.c -rw-r--r-- 1.9 KB
diff-index.c -rw-r--r-- 1.3 KB
diff-tree.c -rw-r--r-- 4.7 KB
diff.c -rw-r--r-- 12.0 KB
fast-export.c -rw-r--r-- 27.2 KB
fetch-pack.c -rw-r--r-- 5.1 KB
fetch.c -rw-r--r-- 33.8 KB
fmt-merge-msg.c -rw-r--r-- 18.1 KB
for-each-ref.c -rw-r--r-- 26.7 KB
fsck.c -rw-r--r-- 17.7 KB
gc.c -rw-r--r-- 9.1 KB
get-tar-commit-id.c -rw-r--r-- 980 bytes
grep.c -rw-r--r-- 24.2 KB
hash-object.c -rw-r--r-- 4.3 KB
help.c -rw-r--r-- 13.0 KB
index-pack.c -rw-r--r-- 43.9 KB
init-db.c -rw-r--r-- 16.3 KB
interpret-trailers.c -rw-r--r-- 1.0 KB
log.c -rw-r--r-- 43.7 KB
ls-files.c -rw-r--r-- 14.8 KB
ls-remote.c -rw-r--r-- 3.0 KB
ls-tree.c -rw-r--r-- 4.8 KB
mailinfo.c -rw-r--r-- 23.9 KB
mailsplit.c -rw-r--r-- 6.7 KB
merge-base.c -rw-r--r-- 5.9 KB
merge-file.c -rw-r--r-- 3.1 KB
merge-index.c -rw-r--r-- 2.2 KB
merge-ours.c -rw-r--r-- 926 bytes
merge-recursive.c -rw-r--r-- 2.0 KB
merge-tree.c -rw-r--r-- 8.8 KB
merge.c -rw-r--r-- 41.6 KB
mktag.c -rw-r--r-- 5.2 KB
mktree.c -rw-r--r-- 4.9 KB
mv.c -rw-r--r-- 8.0 KB
name-rev.c -rw-r--r-- 9.5 KB
notes.c -rw-r--r-- 26.9 KB
pack-objects.c -rw-r--r-- 72.4 KB
pack-redundant.c -rw-r--r-- 15.0 KB
pack-refs.c -rw-r--r-- 600 bytes
patch-id.c -rw-r--r-- 4.0 KB
prune-packed.c -rw-r--r-- 1.5 KB
prune.c -rw-r--r-- 3.7 KB
push.c -rw-r--r-- 16.6 KB
read-tree.c -rw-r--r-- 7.0 KB
receive-pack.c -rw-r--r-- 44.1 KB
reflog.c -rw-r--r-- 18.4 KB
remote-ext.c -rw-r--r-- 5.4 KB
remote-fd.c -rw-r--r-- 1.8 KB
remote.c -rw-r--r-- 44.0 KB
repack.c -rw-r--r-- 11.0 KB
replace.c -rw-r--r-- 13.7 KB
rerere.c -rw-r--r-- 2.9 KB
reset.c -rw-r--r-- 10.7 KB
rev-list.c -rw-r--r-- 10.1 KB
rev-parse.c -rw-r--r-- 19.1 KB
revert.c -rw-r--r-- 6.0 KB
rm.c -rw-r--r-- 11.6 KB
send-pack.c -rw-r--r-- 6.7 KB
shortlog.c -rw-r--r-- 8.3 KB
show-branch.c -rw-r--r-- 22.9 KB
show-ref.c -rw-r--r-- 6.1 KB
stripspace.c -rw-r--r-- 2.6 KB
symbolic-ref.c -rw-r--r-- 1.9 KB
tag.c -rw-r--r-- 18.6 KB
unpack-file.c -rw-r--r-- 807 bytes
unpack-objects.c -rw-r--r-- 13.0 KB
update-index.c -rw-r--r-- 25.8 KB
update-ref.c -rw-r--r-- 11.3 KB
update-server-info.c -rw-r--r-- 620 bytes
upload-archive.c -rw-r--r-- 3.0 KB
var.c -rw-r--r-- 1.7 KB
verify-commit.c -rw-r--r-- 2.3 KB
verify-pack.c -rw-r--r-- 1.9 KB
verify-tag.c -rw-r--r-- 2.1 KB
write-tree.c -rw-r--r-- 1.5 KB

back to top