Added function RNA_property_update_check() to check if an update call is needed,
authorCampbell Barton <ideasman42@gmail.com>
Mon, 25 Oct 2010 21:57:45 +0000 (21:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 25 Oct 2010 21:57:45 +0000 (21:57 +0000)
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.

source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_access.c
source/blender/python/intern/bpy_rna.c
source/gameengine/BlenderRoutines/CMakeLists.txt
source/gameengine/Converter/CMakeLists.txt
source/gameengine/GamePlayer/common/CMakeLists.txt
source/gameengine/GamePlayer/ghost/CMakeLists.txt
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Physics/common/CMakeLists.txt
source/gameengine/VideoTexture/CMakeLists.txt

index ab13196..1ec65c0 100644 (file)
@@ -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 */
 
index 6cb5858..6cdb842 100644 (file)
@@ -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);
index a3b0c47..2bffd7f 100644 (file)
@@ -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);
-       RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+       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,7 +131,9 @@ 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);
-                       RNA_property_update(BPy_GetContext(), &self->ptr, prop_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]);
-       RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+
+       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);
-       RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+
+       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 */
-       RNA_property_update(BPy_GetContext(), ptr, prop);
+       if(RNA_property_update_check(prop)) {
+               RNA_property_update(BPy_GetContext(), ptr, prop);
+       }
 
        return 0;
 }
@@ -1309,8 +1322,10 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
        }
 
        /* Run rna property functions */
-       RNA_property_update(BPy_GetContext(), ptr, prop);
-       
+       if(RNA_property_update_check(prop)) {
+               RNA_property_update(BPy_GetContext(), ptr, prop);
+       }
+
        return ret;
 }
 
@@ -1720,7 +1735,9 @@ static int pyrna_prop_array_ass_subscript( BPy_PropertyArrayRNA *self, PyObject
        }
 
        if(ret != -1) {
-               RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+               if(RNA_property_update_check(self->prop)) {
+                       RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
+               }
        }
 
        return ret;
index 661f9c5..7abdeba 100644 (file)
@@ -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
@@ -16,8 +15,7 @@ SET(INC
        ../../../source/blender/blenfont
        ../../../source/blender/editors/include
        ../../../source/blender/windowmanager
-       ../../../source/blender 
-       ../../../source/blender/include
+       ../../../source/blender
        ../../../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
index e6b5f6c..a23629e 100644 (file)
@@ -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
index 47ac7f7..02c0cb8 100644 (file)
@@ -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
index 6ce9f7b..b6e3813 100644 (file)
@@ -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
index 68f0a0d..2813160 100644 (file)
@@ -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
index 0389280..f67de0f 100644 (file)
@@ -27,7 +27,6 @@
 SET(INC
        .
        ../Dummy
-       ../../../intern/moto/include
 )
 
 SET(SRC
index 1c62448..eb62306 100644 (file)
@@ -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