Added function RNA_property_update_check() to check if an update call is needed,

Simple python benchmark shows this to be about 3x faster in the case where an update isn't needed.

This also speeds up rna function argument parsing, since each arg in a function call did 2 string lookups on the context which were never needed.
This commit is contained in:
Campbell Barton 2010-10-25 21:57:45 +00:00
parent 82fd7f21fc
commit 29605fc06d
10 changed files with 35 additions and 23 deletions

@ -681,6 +681,7 @@ int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_update_main(struct Main *bmain, struct Scene *scene, PointerRNA *ptr, PropertyRNA *prop);
int RNA_property_update_check(struct PropertyRNA *prop);
/* Property Data */

@ -1268,6 +1268,14 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR
}
/* must keep in sync with 'rna_property_update'
* note, its possible this returns a false positive in the case of PROP_CONTEXT_UPDATE
* but this isnt likely to be a performance problem. */
int RNA_property_update_check(PropertyRNA *prop)
{
return (prop->magic != RNA_MAGIC || prop->update || prop->noteflag);
}
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
{
rna_property_update(C, CTX_data_main(C), CTX_data_scene(C), ptr, prop);

@ -120,7 +120,9 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
}
RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
if(RNA_property_update_check(self->prop)) {
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
/* Euler order exception */
if(subtype==MATHUTILS_CB_SUBTYPE_EUL) {
@ -129,9 +131,11 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
short order= pyrna_rotation_euler_order_get(&self->ptr, &prop_eul_order, eul->order);
if(order != eul->order) {
RNA_property_enum_set(&self->ptr, prop_eul_order, eul->order);
if(RNA_property_update_check(prop_eul_order)) {
RNA_property_update(BPy_GetContext(), &self->ptr, prop_eul_order);
}
}
}
return 1;
}
@ -160,7 +164,11 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
RNA_property_float_clamp(&self->ptr, self->prop, &bmo->data[index]);
RNA_property_float_set_index(&self->ptr, self->prop, index, bmo->data[index]);
if(RNA_property_update_check(self->prop)) {
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
return 1;
}
@ -201,7 +209,10 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
/* can ignore clamping here */
RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
if(RNA_property_update_check(self->prop)) {
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
return 1;
}
@ -1235,7 +1246,9 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
/* Run rna property functions */
if(RNA_property_update_check(prop)) {
RNA_property_update(BPy_GetContext(), ptr, prop);
}
return 0;
}
@ -1309,7 +1322,9 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
/* Run rna property functions */
if(RNA_property_update_check(prop)) {
RNA_property_update(BPy_GetContext(), ptr, prop);
}
return ret;
}
@ -1720,8 +1735,10 @@ static int pyrna_prop_array_ass_subscript( BPy_PropertyArrayRNA *self, PyObject
}
if(ret != -1) {
if(RNA_property_update_check(self->prop)) {
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
}
return ret;
}

@ -8,7 +8,6 @@ SET(INC
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
../../../source/gameengine/Converter
../../../source/blender/imbuf
../../../intern/ghost/include
../../../intern/moto/include
../../../source/gameengine/Ketsji
../../../source/blender/blenlib
@ -17,7 +16,6 @@ SET(INC
../../../source/blender/editors/include
../../../source/blender/windowmanager
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
../../../source/blender/makesrna
../../../source/gameengine/Rasterizer
@ -28,7 +26,6 @@ SET(INC
../../../source/gameengine/Physics/common
../../../source/gameengine/Physics/Bullet
../../../source/gameengine/Network/LoopBackNetwork
../../../source/blender/misc
../../../source/blender/blenloader
../../../source/blender/gpu
../../../extern/bullet2/src

@ -41,7 +41,6 @@ SET(INC
../../../source/blender/blenkernel
../../../source/blender/windowmanager
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
../../../source/blender/makesrna
../../../source/gameengine/Rasterizer
@ -54,7 +53,6 @@ SET(INC
../../../source/gameengine/Physics/Bullet
../../../source/gameengine/Physics/Dummy
../../../source/gameengine/Network/LoopBackNetwork
../../../source/blender/misc
../../../source/blender/blenloader
../../../source/blender/gpu
../../../source/blender/ikplugin

@ -39,7 +39,6 @@ SET(INC
../../../../source/blender/blenlib
../../../../source/blender/blenkernel
../../../../source/blender
../../../../source/blender/include
../../../../source/blender/makesdna
../../../../source/gameengine/Rasterizer
../../../../source/gameengine/GameLogic
@ -49,7 +48,6 @@ SET(INC
../../../../source/gameengine/Physics/common
../../../../source/gameengine/Network/LoopBackNetwork
../../../../source/gameengine/GamePlayer/ghost
../../../../source/blender/misc
../../../../source/blender/blenloader
../../../../source/blender/gpu
../../../../extern/glew/include

@ -40,7 +40,6 @@ SET(INC
../../../../source/blender/blenkernel
../../../../source/blender/readblenfile
../../../../source/blender
../../../../source/blender/include
../../../../source/blender/makesdna
../../../../source/blender/makesrna
../../../../source/gameengine/Rasterizer
@ -51,7 +50,6 @@ SET(INC
../../../../source/gameengine/Physics/common
../../../../source/gameengine/Network/LoopBackNetwork
../../../../source/gameengine/GamePlayer/common
../../../../source/blender/misc
../../../../source/blender/blenloader
../../../../source/blender/gpu
../../../../extern/glew/include

@ -32,7 +32,6 @@ SET(INC
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
../../../source/gameengine/Converter
../../../source/blender/imbuf
../../../intern/ghost/include
../../../intern/moto/include
../../../source/gameengine/Ketsji
../../../source/blender/blenlib
@ -40,7 +39,6 @@ SET(INC
../../../source/blender/python
../../../source/blender/python/generic
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
../../../source/gameengine/Rasterizer
../../../source/gameengine/GameLogic
@ -51,7 +49,6 @@ SET(INC
../../../source/gameengine/Physics/common
../../../source/gameengine/Network/LoopBackNetwork
../../../intern/audaspace/intern
../../../source/blender/misc
../../../source/blender/blenloader
../../../source/blender/gpu
../../../extern/glew/include

@ -27,7 +27,6 @@
SET(INC
.
../Dummy
../../../intern/moto/include
)
SET(SRC

@ -33,7 +33,6 @@ SET(INC
../../../source/gameengine/Rasterizer
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
../../../source/gameengine/BlenderRoutines
../../../source/blender/include
../../../source/blender/blenlib
../../../source/blender/blenkernel
../../../source/blender/makesdna