avoid duplicating dirty nodes in native core

This commit is contained in:
Evan Almloff committed 2023-03-28 08:35:57 -05:00
1 parent 9a053a0b51
commit a9b5c92fbb
1 file changed
+7 -3
+7 -3
View File
@@ -16,12 +16,12 @@ use crate::{NodeId, NodeMask};
#[derive(Default)]
struct DirtyNodes {
nodes_dirty: Vec<NodeId>,
nodes_dirty: FxHashSet<NodeId>,
}
impl DirtyNodes {
pub fn add_node(&mut self, node_id: NodeId) {
self.nodes_dirty.push(node_id);
self.nodes_dirty.insert(node_id);
}
pub fn is_empty(&self) -> bool {
@@ -29,10 +29,14 @@ impl DirtyNodes {
}
pub fn pop(&mut self) -> Option<NodeId> {
self.nodes_dirty.pop()
self.nodes_dirty.iter().next().copied().map(|id| {
self.nodes_dirty.remove(&id);
id
})
}
}
/// Tracks the dirty nodes sorted by height for each pass. We resolve passes based on the height of the node in order to avoid resolving any node twice in a pass.
#[derive(Clone, Unique)]
pub struct DirtyNodeStates {
dirty: Arc<FxHashMap<TypeId, RwLock<BTreeMap<u16, DirtyNodes>>>>,