Skip to content

Commit

Permalink
Deleted the node since we don't need it.
Browse files Browse the repository at this point in the history
Switched to using remove instead of get_mut() to make it so we don't
need to do a full scan.

Issue yewstack#479
  • Loading branch information
mrh0057 committed Apr 4, 2020
1 parent b9bd4af commit ca2f74e
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions src/virtual_dom/vlist.rs
Expand Up @@ -124,26 +124,17 @@ impl VDiff for VList {
let mut rights_lookup = HashMap::with_capacity(rights.len());
let mut i = 0 as usize;
for r in rights.drain(..) {
rights_lookup.insert(
r.key().to_owned(),
RightNode {
node: Some(r),
pos: i,
},
);
rights_lookup.insert(r.key().to_owned(), r);
i += 1;
}
loop {
match lefts.next() {
Some(left) => {
let right = rights_lookup.get_mut(&left.key());
let mut right = rights_lookup.remove(&left.key());
match right {
Some(right) => {
previous_sibling = left.apply(
parent,
previous_sibling.as_ref(),
right.node.take(),
);
previous_sibling =
left.apply(parent, previous_sibling.as_ref(), Some(right));
}
None => {
previous_sibling =
Expand All @@ -155,9 +146,7 @@ impl VDiff for VList {
}
}
for right in rights_lookup.values_mut() {
if let Some(mut right) = right.node.take() {
right.detach(parent);
}
right.detach(parent);
}
previous_sibling
} else {
Expand All @@ -183,11 +172,6 @@ impl VDiff for VList {
}
}

struct RightNode {
pos: usize,
node: Option<VNode>,
}

#[cfg(test)]
mod tests {
use crate::{html, Component, ComponentLink, Html, ShouldRender};
Expand Down

0 comments on commit ca2f74e

Please sign in to comment.