[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43592] trunk/blender/source/blender: reduce operator lookups in the UI (could do 4 hash lookups per button).

Campbell Barton ideasman42 at gmail.com
Sun Jan 22 04:30:14 CET 2012


Revision: 43592
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43592
Author:   campbellbarton
Date:     2012-01-22 03:30:07 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
reduce operator lookups in the UI (could do 4 hash lookups per button).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/editors/space_graph/graph_edit.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_text/text_ops.c
    trunk/blender/source/blender/editors/util/ed_util.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2012-01-22 03:21:28 UTC (rev 43591)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2012-01-22 03:30:07 UTC (rev 43592)
@@ -376,6 +376,10 @@
 	bAction *act= ob->poselib; /* never NULL */
 	TimeMarker *marker;
 	
+	wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1);
+
+	BLI_assert(ot != NULL);
+
 	/* set the operator execution context correctly */
 	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
 	
@@ -383,9 +387,9 @@
 	for (marker= act->markers.first; marker; marker= marker->next) {
 		PointerRNA props_ptr;
 		
-		props_ptr = uiItemFullO(layout, "POSELIB_OT_pose_add", 
-						marker->name, ICON_ARMATURE_DATA, NULL, 
-						WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+		props_ptr = uiItemFullO_ptr(layout, ot,
+		                            marker->name, ICON_ARMATURE_DATA, NULL,
+		                            WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
 		
 		RNA_int_set(&props_ptr, "frame", marker->frame);
 		RNA_string_set(&props_ptr, "name", marker->name);

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2012-01-22 03:21:28 UTC (rev 43591)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2012-01-22 03:30:07 UTC (rev 43592)
@@ -5876,8 +5876,8 @@
 	if(obedit->type==OB_SURF) {
 		pup= uiPupMenuBegin(C, "Delete", ICON_NONE);
 		layout= uiPupMenuLayout(pup);
-		uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 0);
-		uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 2);
+		uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0);
+		uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2);
 		uiPupMenuEnd(C, pup);
 	}
 	else {

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2012-01-22 03:21:28 UTC (rev 43591)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2012-01-22 03:30:07 UTC (rev 43592)
@@ -62,6 +62,7 @@
 struct CurveMapping;
 struct Image;
 struct ImageUser;
+struct wmOperatorType;
 struct uiWidgetColors;
 struct Tex;
 struct MTex;
@@ -446,6 +447,7 @@
 uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip);
 uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip);
 
 uiBut *uiDefIconBut(uiBlock *block, 
@@ -466,6 +468,7 @@
 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip);
 
 uiBut *uiDefIconTextBut(uiBlock *block,
 						int type, int retval, int icon, const char *str, 
@@ -485,6 +488,7 @@
 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip);
 uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
+uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip);
 
 /* for passing inputs to ButO buttons */
 struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
@@ -773,6 +777,7 @@
 
 /* items */
 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
+void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value);
 void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value);
 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
 void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
@@ -781,6 +786,8 @@
 void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value);
 void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
 void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
+
+PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag);
 PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
 
 void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-01-22 03:21:28 UTC (rev 43591)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-01-22 03:30:07 UTC (rev 43592)
@@ -2806,16 +2806,12 @@
 	return but;
 }
 
-static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
 {
 	uiBut *but;
-	wmOperatorType *ot;
-	
-	ot= WM_operatortype_find(opname, 0);
 
 	if(!str) {
-		if(ot) str= ot->name;
-		else str= opname;
+		if(ot) str = ot->name;
 	}
 	
 	if ((!tip || tip[0]=='\0') && ot && ot->description) {
@@ -2837,6 +2833,12 @@
 
 	return but;
 }
+static uiBut *UNUSED_FUNCTION(ui_def_but_operator)(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+{
+	wmOperatorType *ot = WM_operatortype_find(opname, 0);
+	if (str == NULL && ot == NULL) str = opname;
+	return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+}
 
 static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
 {
@@ -3043,13 +3045,20 @@
 	ui_check_but(but);
 	return but;
 }
-uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+
+uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
 {
 	uiBut *but;
-	but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
+	but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
 	ui_check_but(but);
 	return but;
 }
+uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+{
+	wmOperatorType *ot = WM_operatortype_find(opname, 0);
+	if (str == NULL && ot == NULL) str = opname;
+	return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+}
 
 uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2,  const char *tip)
 {
@@ -3121,13 +3130,19 @@
 	ui_check_but_and_iconize(but, icon);
 	return but;
 }
-uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
+
+uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
 {
 	uiBut *but;
-	but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip);
+	but= ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip);
 	ui_check_but_and_iconize(but, icon);
 	return but;
 }
+uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
+{
+	wmOperatorType *ot = WM_operatortype_find(opname, 0);
+	return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip);
+}
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list