1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-05 08:47:56 +01:00
git/builtin
Jeff King 2824e1841b list-objects: pass full pathname to callbacks
When we find a blob at "a/b/c", we currently pass this to
our show_object_fn callbacks as two components: "a/b/" and
"c". Callbacks which want the full value then call
path_name(), which concatenates the two. But this is an
inefficient interface; the path is a strbuf, and we could
simply append "c" to it temporarily, then roll back the
length, without creating a new copy.

So we could improve this by teaching the callsites of
path_name() this trick (and there are only 3). But we can
also notice that no callback actually cares about the
broken-down representation, and simply pass each callback
the full path "a/b/c" as a string. The callback code becomes
even simpler, then, as we do not have to worry about freeing
an allocated buffer, nor rolling back our modification to
the strbuf.

This is theoretically less efficient, as some callbacks
would not bother to format the final path component. But in
practice this is not measurable. Since we use the same
strbuf over and over, our work to grow it is amortized, and
we really only pay to memcpy a few bytes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-16 10:41:04 -07:00
..
add.c
annotate.c
apply.c
archive.c
bisect--helper.c
blame.c Sync with 2.3.10 2015-09-28 15:28:31 -07:00
branch.c
bundle.c
cat-file.c
check-attr.c
check-ignore.c
check-mailmap.c
check-ref-format.c
checkout-index.c
checkout.c
clean.c Merge branch 'rs/janitorial' into maint 2015-06-16 14:33:47 -07:00
clone.c clone: simplify string handling in guess_dir_name() 2015-07-09 14:21:29 -07:00
column.c
commit-tree.c
commit.c
config.c
count-objects.c
credential.c
describe.c
diff-files.c
diff-index.c
diff-tree.c
diff.c
fast-export.c
fetch-pack.c
fetch.c
fmt-merge-msg.c
for-each-ref.c Merge branch 'mh/reporting-broken-refs-from-for-each-ref' into maint 2015-08-03 10:41:31 -07:00
fsck.c
gc.c
get-tar-commit-id.c
grep.c
hash-object.c
help.c
index-pack.c Merge branch 'jk/index-pack-reduce-recheck' into maint 2015-07-27 12:21:38 -07:00
init-db.c
interpret-trailers.c
log.c Merge branch 'jc/do-not-feed-tags-to-clear-commit-marks' into maint 2015-07-15 11:41:16 -07:00
ls-files.c
ls-remote.c
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c
merge-file.c Sync with 2.3.10 2015-09-28 15:28:31 -07:00
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c react to errors in xdi_diff 2015-09-28 14:57:10 -07:00
merge.c
mktag.c
mktree.c
mv.c
name-rev.c
notes.c
pack-objects.c list-objects: pass full pathname to callbacks 2016-03-16 10:41:04 -07:00
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c
prune.c
push.c
read-tree.c
receive-pack.c
reflog.c
remote-ext.c
remote-fd.c
remote.c
repack.c
replace.c
rerere.c Sync with 2.3.10 2015-09-28 15:28:31 -07:00
reset.c
rev-list.c list-objects: pass full pathname to callbacks 2016-03-16 10:41:04 -07:00
rev-parse.c
revert.c
rm.c
send-pack.c
shortlog.c
show-branch.c Sync with 2.3.9 2015-09-04 10:34:19 -07:00
show-ref.c
stripspace.c
symbolic-ref.c
tag.c
unpack-file.c
unpack-objects.c
update-index.c
update-ref.c
update-server-info.c
upload-archive.c
var.c
verify-commit.c
verify-pack.c
verify-tag.c
write-tree.c