mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
Fast path for linear deeply nested children
This commit is contained in:
parent
af5b226e53
commit
c0964c2b01
1 changed files with 18 additions and 6 deletions
|
@ -246,11 +246,11 @@ impl Runtime {
|
||||||
|
|
||||||
while let Some(iter) = stack.last_mut() {
|
while let Some(iter) = stack.last_mut() {
|
||||||
let res = iter.with_iter_mut(|iter| {
|
let res = iter.with_iter_mut(|iter| {
|
||||||
let Some(&child) = iter.next() else {
|
let Some(mut child) = iter.next().copied() else {
|
||||||
return IterResult::Empty;
|
return IterResult::Empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(node) = nodes.get_mut(child) {
|
while let Some(node) = nodes.get_mut(child) {
|
||||||
if node.state == ReactiveNodeState::Check
|
if node.state == ReactiveNodeState::Check
|
||||||
|| node.state == ReactiveNodeState::DirtyMarked
|
|| node.state == ReactiveNodeState::DirtyMarked
|
||||||
{
|
{
|
||||||
|
@ -266,11 +266,23 @@ impl Runtime {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(children) = subscribers.get(child) {
|
if let Some(children) = subscribers.get(child) {
|
||||||
return IterResult::NewIter(RefIter::new(
|
let children = children.borrow();
|
||||||
children.borrow(),
|
|
||||||
|children| children.iter(),
|
if !children.is_empty() {
|
||||||
));
|
// avoid going through an iterator in the simple psuedo-recursive case
|
||||||
|
if children.len() == 1 {
|
||||||
|
child = children[0];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IterResult::NewIter(RefIter::new(
|
||||||
|
children,
|
||||||
|
|children| children.iter(),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
IterResult::Continue
|
IterResult::Continue
|
||||||
|
|
Loading…
Reference in a new issue