diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index d22d1ec75b07d..c96d054abdaa2 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -743,10 +743,21 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIterationCursor<'w, 's, D, F> { let ids = self.storage_id_iter.clone(); let remaining_matched: usize = if Self::IS_DENSE { // SAFETY: The if check ensures that storage_id_iter stores TableIds - unsafe { ids.map(|id| tables.get(id.table_id).debug_checked_unwrap().entity_count()).sum() } + unsafe { + ids.map(|id| { + tables + .get(id.table_id) + .debug_checked_unwrap() + .entity_count() + }) + .sum() + } } else { // SAFETY: The if check ensures that storage_id_iter stores ArchetypeIds - unsafe { ids.map(|id| archetypes.get(id.archetype_id).debug_checked_unwrap().len()).sum() } + unsafe { + ids.map(|id| archetypes.get(id.archetype_id).debug_checked_unwrap().len()) + .sum() + } }; remaining_matched + self.current_len - self.current_row } diff --git a/crates/bevy_ecs/src/query/par_iter.rs b/crates/bevy_ecs/src/query/par_iter.rs index 6b59372c97713..8936512c8e222 100644 --- a/crates/bevy_ecs/src/query/par_iter.rs +++ b/crates/bevy_ecs/src/query/par_iter.rs @@ -168,7 +168,12 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> { let tables = unsafe { &self.world.world_metadata().storages().tables }; id_iter // SAFETY: The if check ensures that matched_storage_ids stores TableIds - .map(|id| unsafe { tables.get(id.table_id).debug_checked_unwrap().entity_count() }) + .map(|id| unsafe { + tables + .get(id.table_id) + .debug_checked_unwrap() + .entity_count() + }) .max() } else { let archetypes = &self.world.archetypes();