Reduced lfs_dir_traverse's explicit stack to 3 frames

This is possible thanks to invoxiaamo's optimization of compacting
renames to avoid the O(n^3) nested filters. Not only does this
significantly reduce the runtime cost of that operation, but it
reduces the maximum possible depth of recursion to 3 frames.

Deepest lfs_dir_traverse before:

traverse with commit
'-> traverse with filter
    '-> traverse with move
        '-> traverse with filter

Deepest lfs_dir_traverse after:

traverse with commit
'-> traverse with move
    '-> traverse with filter
This commit is contained in:
Christopher Haster
2022-04-10 23:24:11 -05:00
parent c60c977c25
commit abbfe8e92e

7
lfs.c
View File

@@ -767,11 +767,10 @@ static int lfs_dir_traverse_filter(void *p,
// maximum recursive depth of lfs_dir_traverse, the deepest call:
//
// traverse with commit
// '-> traverse with filter
// '-> traverse with move
// ' traverse with filter
// '-> traverse with move
// '-> traverse with filter
//
#define LFS_DIR_TRAVERSE_DEPTH 4
#define LFS_DIR_TRAVERSE_DEPTH 3
struct lfs_dir_traverse {
const lfs_mdir_t *dir;