@@ -4,6 +4,7 @@ use crate::{
4 events::EventsRegistry,
4 events::EventsRegistry,
5 node::{Attribute, ElementNode, Listener, Node, NodeKind, TextNode},
5 node::{Attribute, ElementNode, Listener, Node, NodeKind, TextNode},
7use std::cmp;
8use std::cmp;
9pub(crate) fn diff(
10pub(crate) fn diff(
@@ -12,7 +13,7 @@ pub(crate) fn diff(
12 registry: &mut EventsRegistry,
13 registry: &mut EventsRegistry,
13 old: Node,
14 old: Node,
14 new: Node,
15 new: Node,
15− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
16+ cached_roots: &mut FxHashSet<CacheId>,
17 match (&new.kind, &old.kind) {
18 match (&new.kind, &old.kind) {
@@ -79,7 +80,7 @@ pub(crate) fn diff(
80 // Both the new and old nodes are cached.
81 // Both the new and old nodes are cached.
81 (&NodeKind::Cached(ref new), &NodeKind::Cached(ref old)) => {
82 (&NodeKind::Cached(ref new), &NodeKind::Cached(ref old)) => {
82− cached_roots.push(new.id);
83+ cached_roots.insert(new.id);
84 if new.id == old.id {
85 if new.id == old.id {
85 // This is the same cached node, so nothing has changed!
86 // This is the same cached node, so nothing has changed!
@@ -95,7 +96,7 @@ pub(crate) fn diff(
95 // we assume that they are pretty different, and it isn't worth diffing
96 // we assume that they are pretty different, and it isn't worth diffing
96 // the subtrees, so we just create the new cached node afresh.
97 // the subtrees, so we just create the new cached node afresh.
97 (&NodeKind::Cached(ref c), _) => {
98 (&NodeKind::Cached(ref c), _) => {
98− cached_roots.push(c.id);
99+ cached_roots.insert(c.id);
99 let new = cached_set.get(c.id);
100 let new = cached_set.get(c.id);
100 create(cached_set, change_list, registry, new, cached_roots);
101 create(cached_set, change_list, registry, new, cached_roots);
101 registry.remove_subtree(&old);
102 registry.remove_subtree(&old);
@@ -187,7 +188,7 @@ fn diff_children(
187 registry: &mut EventsRegistry,
188 registry: &mut EventsRegistry,
188 old: &[Node],
189 old: &[Node],
189 new: &[Node],
190 new: &[Node],
190− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
191+ cached_roots: &mut FxHashSet<CacheId>,
192 debug!(" updating children shared by old and new");
193 debug!(" updating children shared by old and new");
@@ -259,7 +260,7 @@ fn create(
259 change_list: &mut ChangeListBuilder,
260 change_list: &mut ChangeListBuilder,
260 registry: &mut EventsRegistry,
261 registry: &mut EventsRegistry,
261 node: Node,
262 node: Node,
262− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
263+ cached_roots: &mut FxHashSet<CacheId>,
264 match node.kind {
265 match node.kind {
265 NodeKind::Text(TextNode { text }) => {
266 NodeKind::Text(TextNode { text }) => {
@@ -298,7 +299,7 @@ fn create(
300 NodeKind::Cached(c) => {
301 NodeKind::Cached(c) => {
301− cached_roots.push(c.id);
302+ cached_roots.insert(c.id);
302 let node = cached_set.get(c.id);
303 let node = cached_set.get(c.id);
303 create(cached_set, change_list, registry, node, cached_roots)
304 create(cached_set, change_list, registry, node, cached_roots)