From 4b1a502a4917bd2ab4d17677a9eb29cdaa7cfe0c Mon Sep 17 00:00:00 2001 From: Nicola Papale Date: Mon, 26 Jun 2023 17:17:56 +0200 Subject: [PATCH] extract common code from a if block (#8959) Some code could be improved. ## Solution Improve the code --- crates/bevy_ecs/src/world/entity_ref.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 0a74cecfa2..29a63c2220 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -883,13 +883,11 @@ unsafe fn remove_bundle_from_archetype( // check the archetype graph to see if the Bundle has been removed from this archetype in the // past let remove_bundle_result = { - let current_archetype = &mut archetypes[archetype_id]; + let edges = archetypes[archetype_id].edges(); if intersection { - current_archetype - .edges() - .get_remove_bundle(bundle_info.id()) + edges.get_remove_bundle(bundle_info.id()) } else { - current_archetype.edges().get_take_bundle(bundle_info.id()) + edges.get_take_bundle(bundle_info.id()) } }; let result = if let Some(result) = remove_bundle_result {