diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-01 10:34:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-01 10:34:40 +0400 |
commit | 22c2aef77c63cf4cbe19a1c5a8ea4671ef6440bd (patch) | |
tree | 4b4502c3111590f44429da4b55c3e22920c029e6 /source/blender/blenkernel | |
parent | 81dabf76d7392c221decd339945ff3d5678a6023 (diff) |
replace inline string searches with BLI_findstring(), strcmp(..., ""), with char comparisons.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 49 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 |
5 files changed, 33 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 058227e7cc3..5b49d9a9841 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -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"); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 4e5a1977ab0..55d455bc5d3 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -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) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 0c722d81f45..6898615c753 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -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)); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 80962de9730..04fc41e41cc 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -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; } } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a7dd98ff404..64893bb0b5b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -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) { |