Skip to content

Remove SystemSetNode #20100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,29 +659,6 @@ impl Dag {
}
}

/// A [`SystemSet`] with metadata, stored in a [`ScheduleGraph`].
struct SystemSetNode {
inner: InternedSystemSet,
}

impl SystemSetNode {
pub fn new(set: InternedSystemSet) -> Self {
Self { inner: set }
}

pub fn name(&self) -> String {
format!("{:?}", &self.inner)
}

pub fn is_system_type(&self) -> bool {
self.inner.system_type().is_some()
}

pub fn is_anonymous(&self) -> bool {
self.inner.is_anonymous()
}
}

/// A [`SystemWithAccess`] stored in a [`ScheduleGraph`].
pub struct SystemNode {
inner: Option<SystemWithAccess>,
Expand Down Expand Up @@ -785,7 +762,7 @@ enum UninitializedId {
#[derive(Default)]
struct SystemSets {
/// List of system sets in the schedule
sets: SlotMap<SystemSetKey, SystemSetNode>,
sets: SlotMap<SystemSetKey, InternedSystemSet>,
/// List of conditions for each system set, in the same order as `system_sets`
conditions: SecondaryMap<SystemSetKey, Vec<ConditionWithAccess>>,
/// Map from system set to node id
Expand All @@ -795,7 +772,7 @@ struct SystemSets {
impl SystemSets {
fn get_or_add_set(&mut self, set: InternedSystemSet) -> SystemSetKey {
*self.ids.entry(set).or_insert_with(|| {
let key = self.sets.insert(SystemSetNode::new(set));
let key = self.sets.insert(set);
self.conditions.insert(key, Vec::new());
key
})
Expand Down Expand Up @@ -875,7 +852,7 @@ impl ScheduleGraph {

/// Returns the set at the given [`NodeId`], if it exists.
pub fn get_set_at(&self, key: SystemSetKey) -> Option<&dyn SystemSet> {
self.system_sets.sets.get(key).map(|set| &*set.inner)
self.system_sets.sets.get(key).map(|set| &**set)
}

/// Returns the set at the given [`NodeId`].
Expand Down Expand Up @@ -917,10 +894,9 @@ impl ScheduleGraph {
pub fn system_sets(
&self,
) -> impl Iterator<Item = (SystemSetKey, &dyn SystemSet, &[ConditionWithAccess])> {
self.system_sets.sets.iter().filter_map(|(key, set_node)| {
let set = &*set_node.inner;
self.system_sets.sets.iter().filter_map(|(key, set)| {
let conditions = self.system_sets.conditions.get(key)?.as_slice();
Some((key, set, conditions))
Some((key, &**set, conditions))
})
}

Expand Down Expand Up @@ -1704,7 +1680,7 @@ impl ScheduleGraph {
if set.is_anonymous() {
self.anonymous_set_name(id)
} else {
set.name()
format!("{set:?}")
}
}
}
Expand Down Expand Up @@ -1927,7 +1903,7 @@ impl ScheduleGraph {
) -> Result<(), ScheduleBuildError> {
for (&key, systems) in set_systems {
let set = &self.system_sets.sets[key];
if set.is_system_type() {
if set.system_type().is_some() {
let instances = systems.len();
let ambiguous_with = self.ambiguous_with.edges(NodeId::Set(key));
let before = self
Expand Down Expand Up @@ -2033,7 +2009,7 @@ impl ScheduleGraph {
fn names_of_sets_containing_node(&self, id: &NodeId) -> Vec<String> {
let mut sets = <HashSet<_>>::default();
self.traverse_sets_containing_node(*id, &mut |key| {
!self.system_sets.sets[key].is_system_type() && sets.insert(key)
self.system_sets.sets[key].system_type().is_none() && sets.insert(key)
});
let mut sets: Vec<_> = sets
.into_iter()
Expand Down
Loading