diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-22 18:15:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-22 18:15:28 +0400 |
commit | 0bab23633a07942586f963c19d053f26c44d799b (patch) | |
tree | 77065471bb213e0c782aa955eb77d1ca3a728d88 /source/blender/blenkernel | |
parent | 96429a4792cb2b30c8e96ab6cedcd3f6c884fc38 (diff) |
remove inline loops in a few places
replace with defgroup_find_name() and BLI_findstring()
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 19 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/property.c | 10 |
8 files changed, 20 insertions, 52 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 702cb100e18..53f474aa972 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -42,7 +42,7 @@ struct MDeformVert; void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2); struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup); -struct bDeformGroup *defgroup_find_name(struct Object *ob, char *name); +struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name); int defgroup_find_index(struct Object *ob, struct bDeformGroup *dg); int *defgroup_flip_map(struct Object *ob, int use_default); int defgroup_flip_index(struct Object *ob, int index, int use_default); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 41ff3fed8a5..90a3a6ce664 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -368,20 +368,12 @@ void action_groups_remove_channel (bAction *act, FCurve *fcu) /* Find a group with the given name */ bActionGroup *action_groups_find_named (bAction *act, const char name[]) { - bActionGroup *grp; - /* sanity checks */ if (ELEM3(NULL, act, act->groups.first, name) || (name[0] == 0)) return NULL; /* do string comparisons */ - for (grp= act->groups.first; grp; grp= grp->next) { - if (strcmp(grp->name, name) == 0) - return grp; - } - - /* not found */ - return NULL; + return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name)); } /* *************** Pose channels *************** */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 7c8cea12549..292d7be48d6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -43,6 +43,7 @@ #include <stdlib.h> #include <stdio.h> +#include <stddef.h> #include <string.h> #include <fcntl.h> // for open @@ -640,12 +641,8 @@ void BKE_undo_number(bContext *C, int nr) /* go back to the last occurance of name in stack */ void BKE_undo_name(bContext *C, const char *name) { - UndoElem *uel; - - for(uel= undobase.last; uel; uel= uel->prev) { - if(strcmp(name, uel->name)==0) - break; - } + UndoElem *uel= BLI_findstring(&undobase, name, offsetof(UndoElem, name)); + if(uel && uel->prev) { curundo= uel->prev; BKE_undo_step(C, 0); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9520df71b60..24dcb4c5846 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -25,6 +25,9 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <string.h> +#include <stddef.h> + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -47,8 +50,6 @@ #include "BPY_extern.h" #endif -#include <string.h> - /* struct */ struct bContext { @@ -571,13 +572,12 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB static void data_dir_add(ListBase *lb, const char *member) { LinkData *link; - + if(strcmp(member, "scene") == 0) /* exception */ return; - for(link=lb->first; link; link=link->next) - if(strcmp(link->data, member) == 0) - return; + if(BLI_findstring(lb, member, offsetof(LinkData, data))) + return; link= MEM_callocN(sizeof(LinkData), "LinkData"); link->data= (void*)member; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index ccb6ebe1f1e..91584b6236f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -176,7 +176,7 @@ void defvert_flip (MDeformVert *dvert, int *flip_map) } -bDeformGroup *defgroup_find_name (Object *ob, char *name) +bDeformGroup *defgroup_find_name (Object *ob, const char *name) { /* return a pointer to the deform group with this name * or return NULL otherwise. diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f4b931ec52b..708403ab1f7 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -50,6 +50,7 @@ #include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_customdata.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -1003,7 +1004,6 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * static float *get_weights_array(Object *ob, char *vgroup) { - bDeformGroup *curdef; MDeformVert *dvert= NULL; EditMesh *em= NULL; EditVert *eve; @@ -1030,11 +1030,8 @@ static float *get_weights_array(Object *ob, char *vgroup) if(dvert==NULL) return NULL; /* find the group (weak loop-in-loop) */ - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, index++) - if (!strcmp(curdef->name, vgroup)) - break; - - if(curdef) { + index= defgroup_name_index(ob, vgroup); + if(index >= 0) { float *weights; int i, j; @@ -1539,14 +1536,8 @@ KeyBlock *key_get_keyblock(Key *key, int index) /* get the appropriate KeyBlock given a name to search for */ KeyBlock *key_get_named_keyblock(Key *key, const char name[]) { - KeyBlock *kb; - - if (key && name) { - for (kb= key->block.first; kb; kb= kb->next) { - if (strcmp(name, kb->name)==0) - return kb; - } - } + if (key && name) + return BLI_findstring(&key->block, name, offsetof(KeyBlock, name)); return NULL; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 9dca0fa82e4..5af2c64da18 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -734,13 +734,7 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) /* finds a node based on its name */ bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) { - bNode *node=NULL; - - for(node= ntree->nodes.first; node; node= node->next) { - if (strcmp(name, node->name) == 0) - break; - } - return node; + return BLI_findstring(&ntree->nodes, name, offsetof(bNode, name)); } /* finds a node based on given socket */ diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index a2ba7c69b93..d8001572b4f 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -32,6 +32,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stddef.h> #include <string.h> #include <ctype.h> @@ -180,14 +181,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) bProperty *get_ob_property(Object *ob, char *name) { - bProperty *prop; - - prop= ob->prop.first; - while(prop) { - if( strcmp(prop->name, name)==0 ) return prop; - prop= prop->next; - } - return NULL; + return BLI_findstring(&ob->prop, name, offsetof(bProperty, name)); } void set_ob_property(Object *ob, bProperty *propc) |