From a4f762ea51bae8d51777d5167d0cee58f174756c Mon Sep 17 00:00:00 2001 From: Mat Hostetter <4849531+mjhostet@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:49:36 -0700 Subject: [PATCH] Remove redundant bounds check in `Entities::get` (#8108) --- crates/bevy_ecs/src/entity/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 1b1afe3151fc61..843e3262a2bf33 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -571,8 +571,7 @@ impl Entities { /// Returns the location of an [`Entity`]. /// Note: for pending entities, returns `Some(EntityLocation::INVALID)`. pub fn get(&self, entity: Entity) -> Option { - if (entity.index as usize) < self.meta.len() { - let meta = &self.meta[entity.index as usize]; + if let Some(meta) = self.meta.get(entity.index as usize) { if meta.generation != entity.generation || meta.location.archetype_id == ArchetypeId::INVALID {