Skip to content

Commit eda4487

Browse files
committed
Reuse Vec in children iterator cache
1 parent 18161e6 commit eda4487

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/tree/taffy_tree/tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ impl LayoutTree for Taffy {
100100
fn children(&self, node: NodeId) -> Self::ChildIter<'_> {
101101
let mut cache = self.node_children_cache.borrow_mut();
102102
if cache.0 != node {
103-
let mut children = Vec::with_capacity(self.children.len());
104-
find_children_recursive(&mut children, self, node);
105-
*cache = (node, children);
103+
cache.1.clear();
104+
cache.0 = node;
105+
find_children_recursive(&mut cache.1, self, node);
106106
}
107107
RefCellVecIter { children: RefMut::map(cache, |c| &mut c.1), index: 0 }
108108
}

0 commit comments

Comments
 (0)