Skip to content

Commit

Permalink
Use NopFetch instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Gingeh committed Feb 4, 2022
1 parent 6afff3f commit 62d066a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
component::Component,
entity::Entity,
query::{
Fetch, FilterFetch, QueryCombinationIter, QueryEntityError, QueryIter, QueryState,
WorldQuery,
Fetch, FilterFetch, NopFetch, QueryCombinationIter, QueryEntityError, QueryIter,
QueryState, WorldQuery,
},
world::{Mut, World},
};
Expand Down Expand Up @@ -984,11 +984,17 @@ where
/// # targeting_system.system();
/// ```
#[inline]
pub fn contains(&self, entity: Entity) -> bool
where
Q::Fetch: ReadOnlyFetch,
{
self.get(entity).is_ok()
pub fn contains(&self, entity: Entity) -> bool {
unsafe {

This comment has been minimized.

Copy link
@Guvante

Guvante Feb 4, 2022

Contributor

I think the safety comment I used for QueryState::is_empty can work here:

// SAFE: NopFetch does not access any members while &self ensures no one has exclusive access
self.state
.get_unchecked_manual::<NopFetch<Q::State>>(
self.world,
entity,
self.last_change_tick,
self.change_tick,
)
.is_ok()
}
}
}

Expand Down

0 comments on commit 62d066a

Please sign in to comment.