UI: Prevent button vector reallocations on redraws

A bunch of reallocations can be avoided this way, usually the amount of buttons
is quite similar over redraws.

Pull Request: https://projects.blender.org/blender/blender/pulls/134580
This commit is contained in:
Guillermo Venegas
2025-02-17 16:03:45 +01:00
committed by Julian Eisel
parent 8dbd607df5
commit f2b6b6c232

View File

@@ -3849,6 +3849,11 @@ uiBlock *UI_block_begin(const bContext *C,
UI_block_region_set(block, region);
}
/* Prevent reallocations on redraw, most of the time blocks layout will be the same. */
if (block->oldblock) {
block->buttons.reserve(block->oldblock->buttons.size());
}
/* Set window matrix and aspect for region and OpenGL state. */
ui_update_window_matrix(window, region, block);