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/blenlib/intern/listbase.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/blenlib/intern/listbase.c')
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 166f4ed029e..9b4e1720d8b 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -343,6 +343,26 @@ int BLI_findindex(ListBase *listbase, void *vlink) return -1; } +void *BLI_findstring(ListBase *listbase, const char *id, int offset) +{ + Link *link= NULL; + const char *id_iter; + + if (listbase == NULL) return NULL; + + link= listbase->first; + while (link) { + id_iter= ((const char *)link) + offset; + printf("ASS '%s'\n", id_iter); + if(id[0] == id_iter[0] && strcmp(id, id_iter)==0) + return link; + + link= link->next; + } + + return NULL; +} + void BLI_duplicatelist(ListBase *list1, const ListBase *list2) { struct Link *link1, *link2; |