forked from bartvdbraak/blender
replace inline string searches with BLI_findstring(), strcmp(..., ""), with char comparisons.
This commit is contained in:
parent
81dabf76d7
commit
22c2aef77c
@ -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");
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
|
@ -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) {
|
||||
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);
|
||||
|
||||
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, other, copy);
|
||||
BLI_remlink(&dest->data.group, tmp);
|
||||
|
||||
BLI_insertlinkafter(&dest->data.group, loop, copy);
|
||||
BLI_remlink(&dest->data.group, tmp);
|
||||
|
||||
IDP_FreeProperty(tmp);
|
||||
MEM_freeN(tmp);
|
||||
}
|
||||
}
|
||||
IDP_FreeProperty(tmp);
|
||||
MEM_freeN(tmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user