summaryrefslogtreecommitdiff
path: root/list-objects-filter.c
diff options
context:
space:
mode:
authorMatthew DeVore <matvore@google.com>2018-10-18 00:39:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-18 03:49:18 (GMT)
commit8b10a206f090e01ce1ac4d9a10ec769e2409e2b0 (patch)
tree13308fe2d78d914e6e5548d144c4368b5980c471 /list-objects-filter.c
parentd9e6d0942bb9f9fe9e4cca9670181e5b59074bcb (diff)
downloadgit-8b10a206f090e01ce1ac4d9a10ec769e2409e2b0.zip
git-8b10a206f090e01ce1ac4d9a10ec769e2409e2b0.tar.gz
git-8b10a206f090e01ce1ac4d9a10ec769e2409e2b0.tar.bz2
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-filter.c')
-rw-r--r--list-objects-filter.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 09b2b05..765f3df 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -102,9 +102,16 @@ static enum list_objects_filter_result filter_trees_none(
case LOFS_BEGIN_TREE:
case LOFS_BLOB:
- if (filter_data->omits)
+ if (filter_data->omits) {
oidset_insert(filter_data->omits, &obj->oid);
- return LOFR_MARK_SEEN; /* but not LOFR_DO_SHOW (hard omit) */
+ /* _MARK_SEEN but not _DO_SHOW (hard omit) */
+ return LOFR_MARK_SEEN;
+ } else {
+ /*
+ * Not collecting omits so no need to to traverse tree.
+ */
+ return LOFR_SKIP_TREE | LOFR_MARK_SEEN;
+ }
case LOFS_END_TREE:
assert(obj->type == OBJ_TREE);