UI materials: don't reserve in loop when enough capacity (#15919)

# Objective

- UI materials reserve too much capacity in a vec: for every node in the
transparent phase, it reserves enough memory to store all the nodes
- Update #10437 

## Solution

- Only reserve extra memory if there's not enough
- Only reserve the needed memory, not more
This commit is contained in:
François Mockers 2024-10-16 19:59:30 +02:00 committed by GitHub
parent ad9f197150
commit 7495d68b41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -642,9 +642,11 @@ pub fn queue_ui_material_nodes<M: UiMaterial>(
bind_group_data: material.key.clone(), bind_group_data: material.key.clone(),
}, },
); );
transparent_phase if transparent_phase.items.capacity() < extracted_uinodes.uinodes.len() {
.items transparent_phase.items.reserve_exact(
.reserve(extracted_uinodes.uinodes.len()); extracted_uinodes.uinodes.len() - transparent_phase.items.capacity(),
);
}
transparent_phase.add(TransparentUi { transparent_phase.add(TransparentUi {
draw_function, draw_function,
pipeline, pipeline,