Skip to content

Commit 7ae8b53

Browse files
authored
Remove SystemSetNode (#20100)
# Objective `SystemSetNode` doesn't really add much value beyond a couple helper functions for getting the name as a string and checking if its a `SystemTypeSet`. We can replace it entirely and use `InternedSystemSet` directly by inlining these helper functions' usages without sacrificing readability. ## Solution Remove it and replace it with direct `InternedSystemSet` usage. ## Testing Reusing current tests.
1 parent ace0114 commit 7ae8b53

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

crates/bevy_ecs/src/schedule/schedule.rs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -659,29 +659,6 @@ impl Dag {
659659
}
660660
}
661661

662-
/// A [`SystemSet`] with metadata, stored in a [`ScheduleGraph`].
663-
struct SystemSetNode {
664-
inner: InternedSystemSet,
665-
}
666-
667-
impl SystemSetNode {
668-
pub fn new(set: InternedSystemSet) -> Self {
669-
Self { inner: set }
670-
}
671-
672-
pub fn name(&self) -> String {
673-
format!("{:?}", &self.inner)
674-
}
675-
676-
pub fn is_system_type(&self) -> bool {
677-
self.inner.system_type().is_some()
678-
}
679-
680-
pub fn is_anonymous(&self) -> bool {
681-
self.inner.is_anonymous()
682-
}
683-
}
684-
685662
/// A [`SystemWithAccess`] stored in a [`ScheduleGraph`].
686663
pub struct SystemNode {
687664
inner: Option<SystemWithAccess>,
@@ -785,7 +762,7 @@ enum UninitializedId {
785762
#[derive(Default)]
786763
struct SystemSets {
787764
/// List of system sets in the schedule
788-
sets: SlotMap<SystemSetKey, SystemSetNode>,
765+
sets: SlotMap<SystemSetKey, InternedSystemSet>,
789766
/// List of conditions for each system set, in the same order as `system_sets`
790767
conditions: SecondaryMap<SystemSetKey, Vec<ConditionWithAccess>>,
791768
/// Map from system set to node id
@@ -795,7 +772,7 @@ struct SystemSets {
795772
impl SystemSets {
796773
fn get_or_add_set(&mut self, set: InternedSystemSet) -> SystemSetKey {
797774
*self.ids.entry(set).or_insert_with(|| {
798-
let key = self.sets.insert(SystemSetNode::new(set));
775+
let key = self.sets.insert(set);
799776
self.conditions.insert(key, Vec::new());
800777
key
801778
})
@@ -875,7 +852,7 @@ impl ScheduleGraph {
875852

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

881858
/// Returns the set at the given [`NodeId`].
@@ -917,10 +894,9 @@ impl ScheduleGraph {
917894
pub fn system_sets(
918895
&self,
919896
) -> impl Iterator<Item = (SystemSetKey, &dyn SystemSet, &[ConditionWithAccess])> {
920-
self.system_sets.sets.iter().filter_map(|(key, set_node)| {
921-
let set = &*set_node.inner;
897+
self.system_sets.sets.iter().filter_map(|(key, set)| {
922898
let conditions = self.system_sets.conditions.get(key)?.as_slice();
923-
Some((key, set, conditions))
899+
Some((key, &**set, conditions))
924900
})
925901
}
926902

@@ -1704,7 +1680,7 @@ impl ScheduleGraph {
17041680
if set.is_anonymous() {
17051681
self.anonymous_set_name(id)
17061682
} else {
1707-
set.name()
1683+
format!("{set:?}")
17081684
}
17091685
}
17101686
}
@@ -1927,7 +1903,7 @@ impl ScheduleGraph {
19271903
) -> Result<(), ScheduleBuildError> {
19281904
for (&key, systems) in set_systems {
19291905
let set = &self.system_sets.sets[key];
1930-
if set.is_system_type() {
1906+
if set.system_type().is_some() {
19311907
let instances = systems.len();
19321908
let ambiguous_with = self.ambiguous_with.edges(NodeId::Set(key));
19331909
let before = self
@@ -2033,7 +2009,7 @@ impl ScheduleGraph {
20332009
fn names_of_sets_containing_node(&self, id: &NodeId) -> Vec<String> {
20342010
let mut sets = <HashSet<_>>::default();
20352011
self.traverse_sets_containing_node(*id, &mut |key| {
2036-
!self.system_sets.sets[key].is_system_type() && sets.insert(key)
2012+
self.system_sets.sets[key].system_type().is_none() && sets.insert(key)
20372013
});
20382014
let mut sets: Vec<_> = sets
20392015
.into_iter()

0 commit comments

Comments
 (0)