diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index b3e99fe959934a..14c27ccd38f90e 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -929,17 +929,19 @@ unsafe fn take_component( } } -fn contains_component_with_type( +/// # Safety +/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside +/// the archetype +#[inline] +unsafe fn get_component_with_type( world: &World, type_id: TypeId, target: Option, + entity: Entity, location: EntityLocation, -) -> bool { - world - .components - .get_component_id(type_id) - .map(|component_id| contains_component(world, component_id, target, location)) - .unwrap_or(false) +) -> Option<*mut u8> { + let component_id = world.components.get_component_id(type_id)?; + get_component(world, component_id, target, entity, location) } /// # Safety @@ -956,19 +958,17 @@ unsafe fn get_component_and_ticks_with_type( get_component_and_ticks(world, component_id, target, entity, location) } -/// # Safety -/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside -/// the archetype -#[inline] -unsafe fn get_component_with_type( +fn contains_component_with_type( world: &World, type_id: TypeId, target: Option, - entity: Entity, location: EntityLocation, -) -> Option<*mut u8> { - let component_id = world.components.get_component_id(type_id)?; - get_component(world, component_id, target, entity, location) +) -> bool { + world + .components + .get_component_id(type_id) + .map(|component_id| contains_component(world, component_id, target, location)) + .unwrap_or(false) } fn contains_component(