diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-29 18:40:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-29 18:40:26 +0300 |
commit | 5cd837a562d773cdff155ab05084af590341758d (patch) | |
tree | 20609a23f562cbf8ccf91b41af3f80240551b977 /source/blender/blenkernel/intern/library.c | |
parent | d5cef9a30d1febb22b760eb7d5cdac0fd628bb06 (diff) |
* speedup for animating bones, in one scene with sintel and a dragon animated its over 4x faster.
* utility function BLI_findstring to avoid listbase lookup loops everywhere.
eg:
ListBase *lb= objects= &CTX_data_main(C)->object;
Object *ob= BLI_findstring(lb, name, offsetof(ID, name) + 2);
* made some more math functions use const's, (fix warnings I made in previous commits)
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index a32746e3093..c38cfe4ee27 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -38,6 +38,7 @@ #include <ctype.h> #include <string.h> #include <stdlib.h> +#include <stddef.h> #ifdef HAVE_CONFIG_H #include <config.h> @@ -844,18 +845,8 @@ void free_main(Main *mainvar) ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ { - ID *id; - ListBase *lb; - - lb= wich_libbase(G.main, GS(type)); - - id= lb->first; - while(id) { - if(id->name[2]==name[0] && strcmp(id->name+2, name)==0 ) - return id; - id= id->next; - } - return 0; + ListBase *lb= wich_libbase(G.main, GS(type)); + return BLI_findstring(lb, name, offsetof(ID, name) + 2); } static void get_flags_for_id(ID *id, char *buf) @@ -1336,11 +1327,7 @@ void test_idbutton(char *name) if(lb==0) return; /* search for id */ - idtest= lb->first; - while(idtest) { - if( strcmp(idtest->name+2, name)==0) break; - idtest= idtest->next; - } + idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2); if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest); } |