mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
recycle vnode ids
This commit is contained in:
parent
589483d892
commit
73e0be9e65
2 changed files with 19 additions and 0 deletions
|
@ -89,6 +89,15 @@ impl VirtualDom {
|
|||
id,
|
||||
});
|
||||
|
||||
// Remove all VNode ids from the scope
|
||||
for id in self.scopes[id.0]
|
||||
.element_refs_to_drop
|
||||
.borrow_mut()
|
||||
.drain(..)
|
||||
{
|
||||
self.element_refs.try_remove(id.0);
|
||||
}
|
||||
|
||||
self.ensure_drop_safety(id);
|
||||
|
||||
if recursive {
|
||||
|
|
|
@ -893,6 +893,16 @@ impl<'b> VirtualDom {
|
|||
// Clean up the roots, assuming we need to generate mutations for these
|
||||
// This is done last in order to preserve Node ID reclaim order (reclaim in reverse order of claim)
|
||||
self.reclaim_roots(node, gen_muts);
|
||||
|
||||
// Clean up the vnode id
|
||||
self.reclaim_vnode_id(node);
|
||||
}
|
||||
|
||||
fn reclaim_vnode_id(&mut self, node: &'b VNode<'b>) {
|
||||
// Clean up the vnode id
|
||||
if let Some(id) = node.stable_id() {
|
||||
self.element_refs.remove(id.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn reclaim_roots(&mut self, node: &VNode, gen_muts: bool) {
|
||||
|
|
Loading…
Reference in a new issue