diff options
author | Matthew DeVore <matvore@google.com> | 2018-10-18 03:39:15 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-18 06:49:18 +0300 |
commit | 8b10a206f090e01ce1ac4d9a10ec769e2409e2b0 (patch) | |
tree | 13308fe2d78d914e6e5548d144c4368b5980c471 /list-objects.c | |
parent | d9e6d0942bb9f9fe9e4cca9670181e5b59074bcb (diff) |
list-objects: support for skipping tree traversal
The tree:0 filter does not need to traverse the trees that it has
filtered out, so optimize list-objects and list-objects-filter to skip
traversing the trees entirely. Before this patch, we iterated over all
children of the tree, and did nothing for all of them, which was
wasteful.
Signed-off-by: Matthew DeVore <matvore@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects.c')
-rw-r--r-- | list-objects.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/list-objects.c b/list-objects.c index 7a1a0929db..d1e3d217c5 100644 --- a/list-objects.c +++ b/list-objects.c @@ -11,6 +11,7 @@ #include "list-objects-filter-options.h" #include "packfile.h" #include "object-store.h" +#include "trace.h" struct traversal_context { struct rev_info *revs; @@ -184,7 +185,9 @@ static void process_tree(struct traversal_context *ctx, if (base->len) strbuf_addch(base, '/'); - if (!failed_parse) + if (r & LOFR_SKIP_TREE) + trace_printf("Skipping contents of tree %s...\n", base->buf); + else if (!failed_parse) process_tree_contents(ctx, tree, base); if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn) { |