Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/idprop.c')
-rw-r--r--source/blender/blenkernel/intern/idprop.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 2ccb33b088a..a0df73d6c42 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include "BKE_idprop.h"
@@ -491,47 +492,41 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
IDProperty *loop;
- for (loop=group->data.group.first; loop; loop=loop->next) {
- if (BSTR_EQ(loop->name, prop->name)) {
- BLI_insertlink(&group->data.group, loop, prop);
-
- BLI_remlink(&group->data.group, loop);
- IDP_FreeProperty(loop);
- MEM_freeN(loop);
- return;
- }
+ if((loop= IDP_GetPropertyFromGroup(group, prop->name))) {
+ BLI_insertlink(&group->data.group, loop, prop);
+
+ BLI_remlink(&group->data.group, loop);
+ IDP_FreeProperty(loop);
+ MEM_freeN(loop);
+ }
+ else {
+ group->len++;
+ BLI_addtail(&group->data.group, prop);
}
-
- group->len++;
- BLI_addtail(&group->data.group, prop);
}
/*returns 0 if an id property with the same name exists and it failed,
or 1 if it succeeded in adding to the group.*/
int IDP_AddToGroup(IDProperty *group, IDProperty *prop)
{
- IDProperty *loop;
- for (loop=group->data.group.first; loop; loop=loop->next) {
- if (BSTR_EQ(loop->name, prop->name)) return 0;
+ if(IDP_GetPropertyFromGroup(group, prop->name) == NULL) {
+ group->len++;
+ BLI_addtail(&group->data.group, prop);
+ return 1;
}
- group->len++;
- BLI_addtail(&group->data.group, prop);
-
- return 1;
+ return 0;
}
int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew)
{
- IDProperty *loop;
- for (loop=group->data.group.first; loop; loop=loop->next) {
- if (BSTR_EQ(loop->name, pnew->name)) return 0;
+ if(IDP_GetPropertyFromGroup(group, pnew->name) == NULL) {
+ group->len++;
+ BLI_insertlink(&group->data.group, previous, pnew);
+ return 1;
}
-
- group->len++;
- BLI_insertlink(&group->data.group, previous, pnew);
- return 1;
+ return 0;
}
void IDP_RemFromGroup(IDProperty *group, IDProperty *prop)
@@ -542,11 +537,7 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop)
IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
{
- IDProperty *loop;
- for (loop=prop->data.group.first; loop; loop=loop->next) {
- if (strcmp(loop->name, name)==0) return loop;
- }
- return NULL;
+ return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name));
}
typedef struct IDPIter {