Skip to content

Commit

Permalink
Reuse Vec in children iterator cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Sep 25, 2023
1 parent 18161e6 commit eda4487
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tree/taffy_tree/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ impl LayoutTree for Taffy {
fn children(&self, node: NodeId) -> Self::ChildIter<'_> {
let mut cache = self.node_children_cache.borrow_mut();
if cache.0 != node {
let mut children = Vec::with_capacity(self.children.len());
find_children_recursive(&mut children, self, node);
*cache = (node, children);
cache.1.clear();
cache.0 = node;
find_children_recursive(&mut cache.1, self, node);
}
RefCellVecIter { children: RefMut::map(cache, |c| &mut c.1), index: 0 }
}
Expand Down

0 comments on commit eda4487

Please sign in to comment.