Skip to content

Commit

Permalink
blahblah
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Aug 6, 2022
1 parent 1152111 commit 5a08b7d
Show file tree
Hide file tree
Showing 3 changed files with 470 additions and 80 deletions.
12 changes: 10 additions & 2 deletions crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,19 @@ impl<Q: WorldQuery, F: WorldQuery> QueryState<Q, F> {
}

/// Checks if the query is empty for the given [`World`], where the last change and current tick are given.
///
/// This function will only access `world` in ways that are compliant with the access of `Q::ReadOnly` and
/// `F::ReadOnly` (though may not use those `WorldQuery`'s specifically).
#[inline]
pub fn is_empty(&self, world: &World, last_change_tick: u32, change_tick: u32) -> bool {
// SAFETY: NopFetch does not access any members while &self ensures no one has exclusive access
// SAFETY: `&World` ensures we have readonly access to the whole world. A `NopWorldQuery` does not
// access anything so it is trivially true that it cannot violate any aliasing guarantees. We convert
// the `F` world query to its `ReadOnly` which is guaranteed by the `ReadOnlyWorldQuery` trait to not
// access the world mutably. (FIXME) `WorldId` being correct is not currently upheld. The user can just
// pass in any `World` they like.
unsafe {
self.as_nop()
self.as_readonly()
.as_nop()
.iter_unchecked_manual(world, last_change_tick, change_tick)
.next()
.is_none()
Expand Down

0 comments on commit 5a08b7d

Please sign in to comment.