Flag subtree that does not need unmounting
L3P3 opened this issue · comments
IS
When unmounting a subtree, all of it is checked for unmounting tasks to do, including removing every child node.
SHOULD
When unmounting a subtree, only its top-level element is removed and only its subtrees are unmounted that contain unmounting actions.
NOTE
This will speed up some benchmarks. 😉
Keeping track of which subtree needs unmount action is also an overhead. We need to find out if it is worth it.
My current idea is to have a counter for every node that keeps track of the number of childs that need unmounting. When decrementing to 0, we decrement the parent. When incrementing to 1, we increment the parent.
When a hook that needs unmounting is called for the first time, the own counter is incremented. So the counter actually represents unmounting children + own unmounting hooks. Obviously, this means that it cannot go down to 0 again when the node itself has unmounting hooks. This is fine.