Skip to content

Commit 20dbf79

Browse files
Get rid of unnecessary mutable access in ui picking backend (#15630)
## Solution Yeet ## Testing Tested the `simple_picking` example
1 parent 8bf5d99 commit 20dbf79

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

crates/bevy_ui/src/picking_backend.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn ui_picking(
6767
primary_window: Query<Entity, With<PrimaryWindow>>,
6868
ui_scale: Res<UiScale>,
6969
ui_stack: Res<UiStack>,
70-
mut node_query: Query<NodeQuery>,
70+
node_query: Query<NodeQuery>,
7171
mut output: EventWriter<PointerHits>,
7272
) {
7373
// For each camera, the pointer and its position
@@ -119,7 +119,7 @@ pub fn ui_picking(
119119
// reverse the iterator to traverse the tree from closest nodes to furthest
120120
.rev()
121121
{
122-
let Ok(node) = node_query.get_mut(*node_entity) else {
122+
let Ok(node) = node_query.get(*node_entity) else {
123123
continue;
124124
};
125125

@@ -183,11 +183,10 @@ pub fn ui_picking(
183183
for ((camera, pointer), hovered_nodes) in hit_nodes.iter() {
184184
// As soon as a node with a `Block` focus policy is detected, the iteration will stop on it
185185
// because it "captures" the interaction.
186-
let mut iter = node_query.iter_many_mut(hovered_nodes.iter());
187186
let mut picks = Vec::new();
188187
let mut depth = 0.0;
189188

190-
while let Some(node) = iter.fetch_next() {
189+
for node in node_query.iter_many(hovered_nodes) {
191190
let Some(camera_entity) = node
192191
.target_camera
193192
.map(TargetCamera::entity)

0 commit comments

Comments
 (0)