Remove redundant bounds check in Entities::get (#8108)

This commit is contained in:
Mat Hostetter 2023-03-16 15:49:36 -07:00 committed by GitHub
parent 4a62afb97b
commit f3d6c2d90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<EntityLocation> {
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
{