From cd8161b1dda16c5705181d30ab9274951f6525e1 Mon Sep 17 00:00:00 2001 From: shuo Date: Sun, 19 Feb 2023 22:39:00 +0800 Subject: [PATCH 1/2] for disconnected, use Vec instead of HashSet to reduce insert overhead --- crates/bevy_ecs/src/schedule/graph_utils.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/graph_utils.rs b/crates/bevy_ecs/src/schedule/graph_utils.rs index 6f5e3fb96d4d2..4caa5a8b1a316 100644 --- a/crates/bevy_ecs/src/schedule/graph_utils.rs +++ b/crates/bevy_ecs/src/schedule/graph_utils.rs @@ -135,7 +135,7 @@ pub(crate) struct CheckGraphResults { /// Pairs of nodes that have a path connecting them. pub(crate) connected: HashSet<(V, V)>, /// Pairs of nodes that don't have a path connecting them. - pub(crate) disconnected: HashSet<(V, V)>, + pub(crate) disconnected: Vec<(V, V)>, /// Edges that are redundant because a longer path exists. pub(crate) transitive_edges: Vec<(V, V)>, /// Variant of the graph with no transitive edges. @@ -151,7 +151,7 @@ impl Default for CheckGraphResults { Self { reachable: FixedBitSet::new(), connected: HashSet::new(), - disconnected: HashSet::new(), + disconnected: Vec::new(), transitive_edges: Vec::new(), transitive_reduction: DiGraphMap::new(), transitive_closure: DiGraphMap::new(), @@ -198,7 +198,7 @@ where let mut reachable = FixedBitSet::with_capacity(n * n); let mut connected = HashSet::new(); - let mut disconnected = HashSet::new(); + let mut disconnected = Vec::new(); let mut transitive_edges = Vec::new(); let mut transitive_reduction = DiGraphMap::::new(); @@ -255,7 +255,7 @@ where if reachable[index] { connected.insert(pair); } else { - disconnected.insert(pair); + disconnected.push(pair); } } } From c095437242b23ea7c01fa9061280f9b75fd21e8d Mon Sep 17 00:00:00 2001 From: shuo Date: Sun, 19 Feb 2023 23:07:21 +0800 Subject: [PATCH 2/2] fix clippy --- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index e12d5ef1a4c4a..02af9db8b146c 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -1141,7 +1141,7 @@ impl ScheduleGraph { // check for conflicts let mut conflicting_systems = Vec::new(); - for &(a, b) in flat_results.disconnected.iter() { + for &(a, b) in &flat_results.disconnected { if self.ambiguous_with_flattened.contains_edge(a, b) || self.ambiguous_with_all.contains(&a) || self.ambiguous_with_all.contains(&b)