[Bf-blender-cvs] [866b24ac886] master: Cleanup: use continue in loop to reduce right-shift

Campbell Barton noreply at git.blender.org
Wed Jan 11 11:09:06 CET 2023


Commit: 866b24ac886e77b388e5262587778cf6ee434b2a
Author: Campbell Barton
Date:   Wed Jan 11 21:08:15 2023 +1100
Branches: master
https://developer.blender.org/rB866b24ac886e77b388e5262587778cf6ee434b2a

Cleanup: use continue in loop to reduce right-shift

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

M	source/blender/windowmanager/intern/wm_keymap.c

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

diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 807d84dcc51..9e322228884 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1316,12 +1316,13 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
     if (kmi->flag & KMI_INACTIVE) {
       continue;
     }
+    if (!STREQ(kmi->idname, opname)) {
+      continue;
+    }
 
     bool kmi_match = false;
-
-    if (STREQ(kmi->idname, opname)) {
-      if (properties) {
-        /* example of debugging keymaps */
+    if (properties) {
+      /* example of debugging keymaps */
 #if 0
         if (kmi->ptr) {
           if (STREQ("MESH_OT_rip_move", opname)) {
@@ -1333,54 +1334,53 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
         }
 #endif
 
-        if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
-          kmi_match = true;
-        }
-        /* Debug only, helps spotting mismatches between menu entries and shortcuts! */
-        else if (G.debug & G_DEBUG_WM) {
-          if (is_strict && kmi->ptr) {
-            wmOperatorType *ot = WM_operatortype_find(opname, true);
-            if (ot) {
-              /* make a copy of the properties and set unset ones to their default values. */
-              PointerRNA opptr;
-              IDProperty *properties_default = IDP_CopyProperty(kmi->ptr->data);
-
-              RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
-              WM_operator_properties_default(&opptr, true);
-
-              if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) {
-                char kmi_str[128];
-                WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str));
-                /* NOTE: given properties could come from other things than menu entry. */
-                printf(
-                    "%s: Some set values in menu entry match default op values, "
-                    "this might not be desired!\n",
-                    opname);
-                printf("\tkm: '%s', kmi: '%s'\n", keymap->idname, kmi_str);
+      if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
+        kmi_match = true;
+      }
+      /* Debug only, helps spotting mismatches between menu entries and shortcuts! */
+      else if (G.debug & G_DEBUG_WM) {
+        if (is_strict && kmi->ptr) {
+          wmOperatorType *ot = WM_operatortype_find(opname, true);
+          if (ot) {
+            /* make a copy of the properties and set unset ones to their default values. */
+            PointerRNA opptr;
+            IDProperty *properties_default = IDP_CopyProperty(kmi->ptr->data);
+
+            RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
+            WM_operator_properties_default(&opptr, true);
+
+            if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) {
+              char kmi_str[128];
+              WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str));
+              /* NOTE: given properties could come from other things than menu entry. */
+              printf(
+                  "%s: Some set values in menu entry match default op values, "
+                  "this might not be desired!\n",
+                  opname);
+              printf("\tkm: '%s', kmi: '%s'\n", keymap->idname, kmi_str);
 #ifndef NDEBUG
 #  ifdef WITH_PYTHON
-                printf("OPERATOR\n");
-                IDP_print(properties);
-                printf("KEYMAP\n");
-                IDP_print(kmi->ptr->data);
+              printf("OPERATOR\n");
+              IDP_print(properties);
+              printf("KEYMAP\n");
+              IDP_print(kmi->ptr->data);
 #  endif
 #endif
-                printf("\n");
-              }
-
-              IDP_FreeProperty(properties_default);
+              printf("\n");
             }
+
+            IDP_FreeProperty(properties_default);
           }
         }
       }
-      else {
-        kmi_match = true;
-      }
+    }
+    else {
+      kmi_match = true;
+    }
 
-      if (kmi_match) {
-        if ((params == NULL) || params->filter_fn(keymap, kmi, params->user_data)) {
-          return kmi;
-        }
+    if (kmi_match) {
+      if ((params == NULL) || params->filter_fn(keymap, kmi, params->user_data)) {
+        return kmi;
       }
     }
   }



More information about the Bf-blender-cvs mailing list