replace inline string searches with BLI_findstring(), strcmp(..., ""), with char...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 06:34:40 +0000 (06:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 06:34:40 +0000 (06:34 +0000)
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/idprop.c
source/blender/blenkernel/intern/pointcache.c
source/blender/editors/armature/editarmature.c
source/blender/editors/render/render_preview.c
source/blender/makesrna/intern/rna_object_force.c

index 058227e7cc35a120e91d4a633dd1977ba33929d8..5b49d9a9841204a94cc16cf8e3a67b1a69829ed4 100644 (file)
@@ -420,11 +420,11 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name)
                return NULL;
        
        /* See if this channel exists */
-       for (chan=pose->chanbase.first; chan; chan=chan->next) {
-               if (!strcmp (name, chan->name))
-                       return chan;
+       chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
+       if(chan) {
+               return chan;
        }
-       
+
        /* If not, create it and add it */
        chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
        
index 4e5a1977ab01da24b2d861ce4cb772f58d4991c5..55d455bc5d3b5fe26172b0dd4d04c510d00dcc59 100644 (file)
@@ -451,11 +451,10 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
 
                C->data.recursion= 1;
 
-               for(entry=C->wm.store->entries.first; entry; entry=entry->next) {
-                       if(strcmp(entry->name, member) == 0) {
-                               result->ptr= entry->ptr;
-                               done= 1;
-                       }
+               entry= BLI_findstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
+               if(entry) {
+                       result->ptr= entry->ptr;
+                       done= 1;
                }
        }
        if(done!=1 && recursion < 2 && C->wm.region) {
@@ -649,7 +648,7 @@ int CTX_data_equals(const char *member, const char *str)
 
 int CTX_data_dir(const char *member)
 {
-       return (strcmp(member, "") == 0);
+       return member[0] == '\0';
 }
 
 void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
index 0c722d81f45e6d0c84cbfd822371e6140ffdc2ee..6898615c7537b045cbd1eff58b979599715ee2d1 100644 (file)
@@ -386,7 +386,7 @@ VFont *load_vfont(const char *name)
                        vfont->data = vfd;
 
                        /* if there's a font name, use it for the ID name */
-                       if (strcmp(vfd->name, "")!=0) {
+                       if (vfd->name[0] != '\0') {
                                BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2);
                        }
                        BLI_strncpy(vfont->name, name, sizeof(vfont->name));
index 80962de973046fb66f2a19401ff6cbf55b0a9758..04fc41e41cc957b303b1705d2d3354fc7e001f01 100644 (file)
@@ -426,35 +426,30 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
  * When values name and types match, copy the values, else ignore */
 void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
 {
-       IDProperty *loop, *prop;
+       IDProperty *other, *prop;
        for (prop=src->data.group.first; prop; prop=prop->next) {
-               for (loop=dest->data.group.first; loop; loop=loop->next) {
-                       if (strcmp(loop->name, prop->name)==0) {
-                               if(prop->type==loop->type) {
-
-                                       switch (prop->type) {
-                                               case IDP_INT:
-                                               case IDP_FLOAT:
-                                               case IDP_DOUBLE:
-                                                       loop->data= prop->data;
-                                                       break;
-                                               case IDP_GROUP:
-                                                       IDP_SyncGroupValues(loop, prop);
-                                                       break;
-                                               default:
-                                               {
-                                                       IDProperty *tmp= loop;
-                                                       IDProperty *copy= IDP_CopyProperty(prop);
-
-                                                       BLI_insertlinkafter(&dest->data.group, loop, copy);
-                                                       BLI_remlink(&dest->data.group, tmp);
-
-                                                       IDP_FreeProperty(tmp);
-                                                       MEM_freeN(tmp);
-                                               }
-                                       }
+               other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
+               if (other && prop->type==other->type) {
+                       switch (prop->type) {
+                               case IDP_INT:
+                               case IDP_FLOAT:
+                               case IDP_DOUBLE:
+                                       other->data= prop->data;
+                                       break;
+                               case IDP_GROUP:
+                                       IDP_SyncGroupValues(other, prop);
+                                       break;
+                               default:
+                               {
+                                       IDProperty *tmp= other;
+                                       IDProperty *copy= IDP_CopyProperty(prop);
+
+                                       BLI_insertlinkafter(&dest->data.group, other, copy);
+                                       BLI_remlink(&dest->data.group, tmp);
+
+                                       IDP_FreeProperty(tmp);
+                                       MEM_freeN(tmp);
                                }
-                               break;
                        }
                }
        }
index a7dd98ff404d5175b601ab7aed777ac6ba17251b..64893bb0b5bbdc983bc1ad9ab38b3e4af8e51ecf 100644 (file)
@@ -938,7 +938,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
                len = ptcache_path(pid, filename);
                newname += len;
        }
-       if(strcmp(pid->cache->name, "")==0 && (pid->cache->flag & PTCACHE_EXTERNAL)==0) {
+       if(pid->cache->name[0] == '\0' && (pid->cache->flag & PTCACHE_EXTERNAL)==0) {
                idname = (pid->ob->id.name+2);
                /* convert chars to hex so they are always a valid filename */
                while('\0' != *idname) {
index f0f33ec3258f29c381ed9eb01ae1c13a1cda2c59..f4e9c7c5d3e3635db5b7c660d67225f648b019e1 100644 (file)
@@ -804,7 +804,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
                                                
                                                for (ct= targets.first; ct; ct= ct->next) {
                                                        if (ct->tar == srcArm) {
-                                                               if (strcmp(ct->subtarget, "")==0) {
+                                                               if (ct->subtarget[0] == '\0') {
                                                                        ct->tar = tarArm;
                                                                }
                                                                else if (strcmp(ct->subtarget, pchan->name)==0) {
@@ -851,7 +851,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
                                        
                                        for (ct= targets.first; ct; ct= ct->next) {
                                                if (ct->tar == srcArm) {
-                                                       if (strcmp(ct->subtarget, "")==0) {
+                                                       if (ct->subtarget[0] == '\0') {
                                                                ct->tar = tarArm;
                                                        }
                                                        else if (strcmp(ct->subtarget, pchan->name)==0) {
index 905f88c5f901575960c8226db7b1ba08a6b763b1..1abf5df223c86c6c9a9f89cb2f4e02d5790d739f 100644 (file)
@@ -314,15 +314,6 @@ void ED_preview_free_dbase(void)
                free_main(pr_main);
 }
 
-static Object *find_object(ListBase *lb, const char *name)
-{
-       Object *ob;
-       for(ob= lb->first; ob; ob= ob->id.next)
-               if(strcmp(ob->id.name+2, name)==0)
-                       break;
-       return ob;
-}
-
 static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
 {
        if(mat) {
@@ -529,12 +520,12 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
                        if(la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
                                sce->lay= 1<<MA_ATMOS;
                                sce->world= scene->world;
-                               sce->camera= (Object *)find_object(&pr_main->object, "CameraAtmo");
+                               sce->camera= (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name)+2);
                        }
                        else {
                                sce->lay= 1<<MA_LAMP;
                                sce->world= NULL;
-                               sce->camera= (Object *)find_object(&pr_main->object, "Camera");
+                               sce->camera= (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name)+2);
                        }
                        sce->r.mode &= ~R_SHADOW;
                        
index 0619f5e19b6442a1c07fcee62e0980735b46788d..a4fbd7c160e1452980714d11ab617fb19f935834 100644 (file)
@@ -190,7 +190,7 @@ static void rna_Cache_idname_change(Main *bmain, Scene *scene, PointerRNA *ptr)
                for(pid=pidlist.first; pid; pid=pid->next) {
                        if(pid->cache==cache)
                                pid2 = pid;
-                       else if(strcmp(cache->name, "") && strcmp(cache->name,pid->cache->name)==0) {
+                       else if(cache->name[0] != '\0' && strcmp(cache->name,pid->cache->name)==0) {
                                /*TODO: report "name exists" to user */
                                strcpy(cache->name, cache->prev_name);
                                new_name = 0;