@@ -4,6 +4,7 @@ use crate::{
44 events::EventsRegistry,
55 node::{Attribute, ElementNode, Listener, Node, NodeKind, TextNode},
66};
7+use fxhash::FxHashSet;
78use std::cmp;
89
910pub(crate) fn diff(
@@ -12,7 +13,7 @@ pub(crate) fn diff(
1213 registry: &mut EventsRegistry,
1314 old: Node,
1415 new: Node,
15− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
16+ cached_roots: &mut FxHashSet<CacheId>,
1617) {
1718 match (&new.kind, &old.kind) {
1819 (
@@ -79,7 +80,7 @@ pub(crate) fn diff(
7980
8081 // Both the new and old nodes are cached.
8182 (&NodeKind::Cached(ref new), &NodeKind::Cached(ref old)) => {
82− cached_roots.push(new.id);
83+ cached_roots.insert(new.id);
8384
8485 if new.id == old.id {
8586 // This is the same cached node, so nothing has changed!
@@ -95,7 +96,7 @@ pub(crate) fn diff(
9596 // we assume that they are pretty different, and it isn't worth diffing
9697 // the subtrees, so we just create the new cached node afresh.
9798 (&NodeKind::Cached(ref c), _) => {
98− cached_roots.push(c.id);
99+ cached_roots.insert(c.id);
99100 let new = cached_set.get(c.id);
100101 create(cached_set, change_list, registry, new, cached_roots);
101102 registry.remove_subtree(&old);
@@ -187,7 +188,7 @@ fn diff_children(
187188 registry: &mut EventsRegistry,
188189 old: &[Node],
189190 new: &[Node],
190− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
191+ cached_roots: &mut FxHashSet<CacheId>,
191192) {
192193 debug!(" updating children shared by old and new");
193194
@@ -259,7 +260,7 @@ fn create(
259260 change_list: &mut ChangeListBuilder,
260261 registry: &mut EventsRegistry,
261262 node: Node,
262− cached_roots: &mut bumpalo::collections::Vec<CacheId>,
263+ cached_roots: &mut FxHashSet<CacheId>,
263264) {
264265 match node.kind {
265266 NodeKind::Text(TextNode { text }) => {
@@ -298,7 +299,7 @@ fn create(
298299 }
299300 }
300301 NodeKind::Cached(c) => {
301− cached_roots.push(c.id);
302+ cached_roots.insert(c.id);
302303 let node = cached_set.get(c.id);
303304 create(cached_set, change_list, registry, node, cached_roots)
304305 }