summaryrefslogtreecommitdiff
path: root/ecs/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-01-20 18:14:33 +0100
committerHampusM <hampus@hampusmat.com>2025-01-20 18:14:33 +0100
commit037f6c7888dbc54868b808ad968df469f0a4e5ac (patch)
tree27d606fdbb7704e79b815be0be128c350df846c9 /ecs/src
parente2c15f3f2fb6a67d615322020a78bf334621b16c (diff)
perf(ecs): use Query::iter_with_euids to iterate phases
Diffstat (limited to 'ecs/src')
-rw-r--r--ecs/src/lib.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 1b9a31b..1fb755f 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -269,7 +269,7 @@ impl World
{
let phase_query = self.query::<(&Phase, &Relationship<ChildOf, Phase>), ()>();
- for (index, (_, phase_rel)) in phase_query.iter().enumerate() {
+ for (child_phase_euid, (_, phase_rel)) in phase_query.iter_with_euids() {
if !phase_rel
.target_uids()
.any(|phase_euid| phase_euid == parent_phase_euid)
@@ -277,13 +277,8 @@ impl World
continue;
}
- let phase_euid = phase_query
- .get_entity_uid(index)
- .expect("Cannot get current query iteration entity UID");
-
- self.query_and_run_systems(phase_euid);
-
- self.perform_child_phases(phase_euid);
+ self.query_and_run_systems(child_phase_euid);
+ self.perform_child_phases(child_phase_euid);
}
}
@@ -292,18 +287,13 @@ impl World
let phase_query =
self.query::<(&Phase,), Not<With<Relationship<ChildOf, Phase>>>>();
- for (index, (_,)) in phase_query.iter().enumerate() {
- let child_phase_euid = phase_query
- .get_entity_uid(index)
- .expect("Cannot get current query iteration entity UID");
-
- if child_phase_euid == *START_PHASE {
+ for (phase_euid, (_,)) in phase_query.iter_with_euids() {
+ if phase_euid == *START_PHASE {
continue;
}
- self.query_and_run_systems(child_phase_euid);
-
- self.perform_child_phases(child_phase_euid);
+ self.query_and_run_systems(phase_euid);
+ self.perform_child_phases(phase_euid);
}
}