From f2b6b6c232ea71f05fd52c8a1d846a85cd356f7b Mon Sep 17 00:00:00 2001 From: Guillermo Venegas Date: Mon, 17 Feb 2025 16:03:45 +0100 Subject: [PATCH] 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 --- source/blender/editors/interface/interface.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index f7e273e1df6..ae38ce0678c 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -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);