From 20dbf790a683263fceeb0681e988dcd65416034c Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 3 Oct 2024 21:30:52 +0000 Subject: [PATCH] Get rid of unnecessary mutable access in ui picking backend (#15630) ## Solution Yeet ## Testing Tested the `simple_picking` example --- crates/bevy_ui/src/picking_backend.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index d66c3f995c..da708511bb 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -67,7 +67,7 @@ pub fn ui_picking( primary_window: Query>, ui_scale: Res, ui_stack: Res, - mut node_query: Query, + node_query: Query, mut output: EventWriter, ) { // For each camera, the pointer and its position @@ -119,7 +119,7 @@ pub fn ui_picking( // reverse the iterator to traverse the tree from closest nodes to furthest .rev() { - let Ok(node) = node_query.get_mut(*node_entity) else { + let Ok(node) = node_query.get(*node_entity) else { continue; }; @@ -183,11 +183,10 @@ pub fn ui_picking( for ((camera, pointer), hovered_nodes) in hit_nodes.iter() { // As soon as a node with a `Block` focus policy is detected, the iteration will stop on it // because it "captures" the interaction. - let mut iter = node_query.iter_many_mut(hovered_nodes.iter()); let mut picks = Vec::new(); let mut depth = 0.0; - while let Some(node) = iter.fetch_next() { + for node in node_query.iter_many(hovered_nodes) { let Some(camera_entity) = node .target_camera .map(TargetCamera::entity)