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/editors | |
parent | 96429a4792cb2b30c8e96ab6cedcd3f6c884fc38 (diff) |
remove inline loops in a few places
replace with defgroup_find_name() and BLI_findstring()
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 26 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 8 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 14 |
4 files changed, 11 insertions, 47 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0a58ad64e2f..ab236de9ac5 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -522,20 +522,12 @@ ListBase builtin_keyingsets = {NULL, NULL}; /* Find KeyingSet type info given a name */ KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) { - KeyingSetInfo *ksi; - /* sanity checks */ if ((name == NULL) || (name[0] == 0)) return NULL; /* search by comparing names */ - for (ksi = keyingset_type_infos.first; ksi; ksi = ksi->next) { - if (strcmp(ksi->idname, name) == 0) - return ksi; - } - - /* no matches found */ - return NULL; + return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname)); } /* Find builtin KeyingSet by name */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index d8374e1ed85..a37c8a6d118 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -486,13 +486,7 @@ void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermod /* checks if an EditBone with a matching name already, returning the matching bone if it exists */ static EditBone *editbone_name_exists (ListBase *edbo, const char *name) { - EditBone *eBone; - - for (eBone=edbo->first; eBone; eBone=eBone->next) { - if (!strcmp(name, eBone->name)) - return eBone; - } - return NULL; + return BLI_findstring(edbo, name, offsetof(EditBone, name)); } /* note: there's a unique_bone_name() too! */ @@ -4657,7 +4651,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m bArmature *arm= par->data; Bone **bonelist, *bone; bDeformGroup **dgrouplist, **dgroupflip; - bDeformGroup *dgroup, *curdg; + bDeformGroup *dgroup; bPoseChannel *pchan; Mesh *mesh; Mat4 *bbone = NULL; @@ -4751,13 +4745,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m // 0 = don't strip off number extensions flip_side_name(name, dgroup->name, FALSE); - - for (curdg = ob->defbase.first; curdg; curdg=curdg->next) { - if (!strcmp(curdg->name, name)) - break; - } - - dgroupflip[j] = curdg; + dgroupflip[j] = defgroup_find_name(ob, name); } } @@ -5514,11 +5502,9 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep) } if (modifiers_usesArmature(ob, arm)) { - bDeformGroup *dg; - /* bone name in defgroup */ - for (dg=ob->defbase.first; dg; dg=dg->next) { - if (!strcmp(dg->name, oldname)) - BLI_strncpy(dg->name, newname, MAXBONENAME); + bDeformGroup *dg= defgroup_find_name(ob, oldname); + if(dg) { + BLI_strncpy(dg->name, newname, MAXBONENAME); } } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index f78819d1b74..7cef819a795 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -55,6 +55,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_deform.h" #include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_library.h" @@ -184,12 +185,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* Join this object's vertex groups to the base one's */ for(dg=base->object->defbase.first; dg; dg=dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ - for(odg=ob->defbase.first; odg; odg=odg->next) { - if(!strcmp(odg->name, dg->name)) { - break; - } - } - if(!odg) { + if(!defgroup_find_name(ob, dg->name)) { odg = MEM_callocN(sizeof(bDeformGroup), "join deformGroup"); memcpy(odg, dg, sizeof(bDeformGroup)); BLI_addtail(&ob->defbase, odg); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 5cdabcab41a..377a4d15675 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -532,18 +532,8 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) } void ED_vgroup_select_by_name(Object *ob, char *name) -{ - bDeformGroup *curdef; - int actdef= 1; - - for(curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){ - if(!strcmp(curdef->name, name)) { - ob->actdef= actdef; - return; - } - } - - ob->actdef= 0; // this signals on painting to create a new one, if a bone in posemode is selected */ +{ /* note: ob->actdef==0 signals on painting to create a new one, if a bone in posemode is selected */ + ob->actdef= defgroup_name_index(ob, name) + 1; } /********************** Operator Implementations *********************/ |