[Bf-committers] simple test_object_materials speedup

Campbell Barton cbarton at metavr.com
Thu Sep 14 19:32:24 CEST 2006

Just noticed  test_object_materials does a search for an obdata's object 
every time it runs.

This can be slow on scenes with many objects.

How about we  add an arg to void test_object_materials(ID *id)
make it
void test_object_materials(ID *id, Object *ob)

so in cases where the object is known, the search can be avoided. 
otherwise its null and will search for the object as is done now.

Looking at places the functions used. the obdata is obviously available.

test_object_materials((ID *)me);
./source/blender/python/api2_2x/Mesh.c:5785:    test_object_materials( ( 
ID * ) self->mesh );
test_object_materials( ( ID * ) self->mesh );
test_object_materials( ( ID * ) self->metaball );
./source/blender/python/api2_2x/NMesh.c:2845:   test_object_materials( ( 
ID * ) mesh );
./source/blender/python/api2_2x/Object.c:1607:  test_object_materials( id );
./source/blender/python/api2_2x/Scene.c:1359:   test_object_materials( 
(ID *)object->data );
./source/blender/src/meshtools.c:453:   test_object_materials((ID *)me);

- Cam

More information about the Bf-committers mailing list