diff options
author | Hans Goudey <h.goudey@me.com> | 2020-08-27 22:36:01 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-08-27 22:36:01 +0300 |
commit | 770cc66f75628d832fc3c3bff62057c7e9bd751a (patch) | |
tree | 18b7dcc1068c8a0bb94f32e73a7dbb5d902971a6 /source/blender/editors/interface/interface_panel.c | |
parent | a8766de5d59be699f47f7daedf8ac35f46e9b2e2 (diff) |
UI: Avoid redundant loops in region panel handler
Currently the panel handler loops through every block and every button
for every single panel. This commit moves that check to happen a single
time at the beginning.
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index fe8e2eabea1..c49b61c53b7 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -2388,6 +2388,8 @@ int ui_handler_panel_region(bContext *C, return retval; } + const bool region_has_active_button = (ui_region_find_active_but(region) != NULL); + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { Panel *panel = block->panel; if (panel == NULL || panel->type == NULL) { @@ -2402,7 +2404,7 @@ int ui_handler_panel_region(bContext *C, int my = event->y; ui_window_to_block(region, block, &mx, &my); - uiPanelMouseState mouse_state = ui_panel_mouse_state_get(block, panel, mx, my); + const uiPanelMouseState mouse_state = ui_panel_mouse_state_get(block, panel, mx, my); /* The panel collapse / expand key "A" is special as it takes priority over * active button handling. */ @@ -2415,7 +2417,7 @@ int ui_handler_panel_region(bContext *C, } /* Don't do any other panel handling with an active button. */ - if (ui_region_find_active_but(region) != NULL) { + if (region_has_active_button) { continue; } |