Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Mar 30, 2024
1 parent 0ee23d3 commit 7ac283c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions crates/bevy_ecs/src/query/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_ecs/src/query/par_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7ac283c

Please sign in to comment.