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 ab1319653b8fc687c5317cc235a0f9a665480774..1ec65c0e59b624145f82370a0e53b6112dbc5db6 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 6cb5858648a75656613adcc39c80d28b50a6933d..6cdb842fbc25330f46697946fcd60489b8b91f05 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 a3b0c4739c4a803cf275794d394eab0edf2711a0..2bffd7f6b88fc6545d16df19486811a473f4fd58 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 661f9c5b25daf84f8a1775d1a2f006070327d303..7abdeba07400033514ec11a011ecdd6314cbf554 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 e6b5f6c81a0640c4121449bfbb4371e3206faf11..a23629e33413bd6c2858dc12037ff8f549cab3a8 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 47ac7f73a51fedc2d6c32149ecc59c3079413ea6..02c0cb8a83c3e7e806aeeec3d49e21cfb2efe0a1 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 6ce9f7be280ed979119670df7bd5473d4af45127..b6e381359df26614531466c558740b3a46b12f48 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 68f0a0de9940845af6a80692420afaf2b561bb28..2813160fb820335ebb762f984e35e968a4290371 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 0389280340f3075773017de52952aeac6734db3b..f67de0f77d02d67ba9f805430d7695883995a7ae 100644 (file)
@@ -27,7 +27,6 @@
 SET(INC
        .
        ../Dummy
-       ../../../intern/moto/include
 )
 
 SET(SRC
index 1c624482d30cffd40574a10b0bc236d41d24e866..eb623065a759c5391a1baba0d5b85523f0ac46f0 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