[Bf-blender-cvs] [87fda5bc608] master: Cleanup: const assignments to simplify code

Campbell Barton noreply at git.blender.org
Tue May 21 07:21:14 CEST 2019


Commit: 87fda5bc608322dbddbe57303ad3ae5d737216e0
Author: Campbell Barton
Date:   Tue May 21 12:30:07 2019 +1000
Branches: master
https://developer.blender.org/rB87fda5bc608322dbddbe57303ad3ae5d737216e0

Cleanup: const assignments to simplify code

Also avoids using uninitialized vars.

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

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

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index df4b18477fc..9632bcd35e4 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1858,12 +1858,7 @@ void uiItemFullR(uiLayout *layout,
                  int icon)
 {
   uiBlock *block = layout->root->block;
-  uiBut *but = NULL;
-  PropertyType type;
   char namestr[UI_MAX_NAME_STR];
-  int len, w, h;
-  bool slider, toggle, expand, icon_only, no_bg, compact;
-  bool is_array;
   const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
 
   /* By default 'use_prop_sep' uses a separate column for labels.
@@ -1888,11 +1883,11 @@ void uiItemFullR(uiLayout *layout,
   UI_block_layout_set_current(block, layout);
 
   /* retrieve info */
-  type = RNA_property_type(prop);
-  is_array = RNA_property_array_check(prop);
-  len = (is_array) ? RNA_property_array_length(ptr, prop) : 0;
+  const PropertyType type = RNA_property_type(prop);
+  const bool is_array = RNA_property_array_check(prop);
+  const int len = (is_array) ? RNA_property_array_length(ptr, prop) : 0;
 
-  icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
+  const bool icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
 
   /* set name and icon */
   if (!name) {
@@ -1979,13 +1974,14 @@ void uiItemFullR(uiLayout *layout,
     flag |= UI_ITEM_R_EXPAND;
   }
 
-  slider = (flag & UI_ITEM_R_SLIDER) != 0;
-  toggle = (flag & UI_ITEM_R_TOGGLE) != 0;
-  expand = (flag & UI_ITEM_R_EXPAND) != 0;
-  no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
-  compact = (flag & UI_ITEM_R_COMPACT) != 0;
+  const bool slider = (flag & UI_ITEM_R_SLIDER) != 0;
+  const bool toggle = (flag & UI_ITEM_R_TOGGLE) != 0;
+  const bool expand = (flag & UI_ITEM_R_EXPAND) != 0;
+  const bool no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
+  const bool compact = (flag & UI_ITEM_R_COMPACT) != 0;
 
   /* get size */
+  int w, h;
   ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
 
   int prev_emboss = layout->emboss;
@@ -1993,6 +1989,8 @@ void uiItemFullR(uiLayout *layout,
     layout->emboss = UI_EMBOSS_NONE;
   }
 
+  uiBut *but = NULL;
+
   /* Split the label / property. */
   uiLayout *layout_parent = layout;
   if (use_prop_sep) {



More information about the Bf-blender-cvs mailing list