Skip to content

Commit

Permalink
perf: Remove unused field __cache_children (#509)
Browse files Browse the repository at this point in the history
Together with __owner, this led to O(n^2) space where n is the number
of nodes in directory, and yet it was not used anywhere.
  • Loading branch information
tomtomjhj authored Oct 15, 2024
1 parent 43efd32 commit 2cf57c6
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions autoload/fern/internal/node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ function! fern#internal#node#children(node, provider, token, ...) abort
\}, a:0 ? a:1 : {})
if a:node.status is# s:STATUS_NONE
return s:Promise.reject('leaf node does not have children')
elseif has_key(a:node.concealed, '__cache_children') && options.cache
" Return a fresh copy of cached children so that status won't be cached
return s:AsyncLambda.map(
\ a:node.concealed.__cache_children,
\ { v -> deepcopy(v) },
\)
elseif has_key(a:node.concealed, '__promise_children')
return a:node.concealed.__promise_children
endif
Expand All @@ -102,7 +96,6 @@ function! fern#internal#node#children(node, provider, token, ...) abort
\ '__owner': a:node,
\ })
\ }))
\.then({ v -> s:Lambda.pass(v, s:Lambda.let(a:node.concealed, '__cache_children', v)) })
\.finally({ -> Done() })
\.finally({ -> Profile() })
let a:node.concealed.__promise_children = p
Expand Down Expand Up @@ -199,7 +192,6 @@ function! fern#internal#node#collapse(node, nodes, provider, comparator, token)
\.finally({ -> Done() })
\.finally({ -> Profile() })
call p.then({ -> s:Lambda.let(a:node, 'status', s:STATUS_COLLAPSED) })
\.then({ -> s:Lambda.unlet(a:node.concealed, '__cache_children') })
let a:node.concealed.__promise_collapse = p
\.finally({ -> s:Lambda.unlet(a:node.concealed, '__promise_collapse') })
return p
Expand Down

0 comments on commit 2cf57c6

Please sign in to comment.