mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-10-30 16:15:40 +01:00
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:
7
lfs.c
7
lfs.c
@@ -767,11 +767,10 @@ static int lfs_dir_traverse_filter(void *p,
|
|||||||
// maximum recursive depth of lfs_dir_traverse, the deepest call:
|
// maximum recursive depth of lfs_dir_traverse, the deepest call:
|
||||||
//
|
//
|
||||||
// traverse with commit
|
// traverse with commit
|
||||||
// '-> traverse with filter
|
// '-> traverse with move
|
||||||
// '-> traverse with move
|
// '-> traverse with filter
|
||||||
// ' traverse with filter
|
|
||||||
//
|
//
|
||||||
#define LFS_DIR_TRAVERSE_DEPTH 4
|
#define LFS_DIR_TRAVERSE_DEPTH 3
|
||||||
|
|
||||||
struct lfs_dir_traverse {
|
struct lfs_dir_traverse {
|
||||||
const lfs_mdir_t *dir;
|
const lfs_mdir_t *dir;
|
||||||
|
|||||||
Reference in New Issue
Block a user