[Bf-blender-cvs] [8649ac0ca86] master: Cleanup: early exit ui_but_extra_operator_icon_mouse_over_get

Campbell Barton noreply at git.blender.org
Fri Aug 12 02:48:53 CEST 2022


Commit: 8649ac0ca869a12872865500ce8b99eaedb97f97
Author: Campbell Barton
Date:   Fri Aug 12 10:41:39 2022 +1000
Branches: master
https://developer.blender.org/rB8649ac0ca869a12872865500ce8b99eaedb97f97

Cleanup: early exit ui_but_extra_operator_icon_mouse_over_get

Early exit when the button has no extra icons, avoiding a redundant
transformation from mouse to button coordinates.

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 5d4c8a342e2..6ee421fb4d2 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4344,15 +4344,18 @@ static uiButExtraOpIcon *ui_but_extra_operator_icon_mouse_over_get(uiBut *but,
                                                                    ARegion *region,
                                                                    const wmEvent *event)
 {
-  float xmax = but->rect.xmax;
-  const float icon_size = 0.8f * BLI_rctf_size_y(&but->rect); /* ICON_SIZE_FROM_BUTRECT */
-  int x = event->xy[0], y = event->xy[1];
+  if (BLI_listbase_is_empty(&but->extra_op_icons)) {
+    return NULL;
+  }
 
+  int x = event->xy[0], y = event->xy[1];
   ui_window_to_block(region, but->block, &x, &y);
   if (!BLI_rctf_isect_pt(&but->rect, x, y)) {
     return NULL;
   }
 
+  const float icon_size = 0.8f * BLI_rctf_size_y(&but->rect); /* ICON_SIZE_FROM_BUTRECT */
+  float xmax = but->rect.xmax;
   /* Same as in 'widget_draw_extra_icons', icon padding from the right edge. */
   xmax -= 0.2 * icon_size;



More information about the Bf-blender-cvs mailing list