From 5351e752c2c4afef5fc07d862e34e5bb1bcde6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 8 Nov 2023 00:23:22 +0100 Subject: [PATCH] don't reserve size inside loop --- crates/bevy_ui/src/render/ui_material_pipeline.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 11885942822a4..5b33dbfe1719a 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -731,9 +731,12 @@ pub fn queue_ui_material_nodes( { let draw_function = draw_functions.read().id::>(); - for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() { - let material = render_materials.get(&extracted_uinode.material).unwrap(); - for (view, mut transparent_phase) in &mut views { + for (view, mut transparent_phase) in &mut views { + transparent_phase + .items + .reserve(extracted_uinodes.uinodes.len()); + for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() { + let material = render_materials.get(&extracted_uinode.material).unwrap(); let pipeline = pipelines.specialize( &pipeline_cache, &ui_material_pipeline, @@ -742,9 +745,6 @@ pub fn queue_ui_material_nodes( bind_group_data: material.key.clone(), }, ); - transparent_phase - .items - .reserve(extracted_uinodes.uinodes.len()); transparent_phase.add(TransparentUi { draw_function, pipeline,