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:
authorCampbell Barton <ideasman42@gmail.com>2012-08-18 20:16:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-18 20:16:13 +0400
commit27b4b45543c0f7690a1978a60591a0b5c0f1adbb (patch)
tree14c54494059de30d8d4c8a24ec8400b8bcc83ff5 /source/blender/editors
parente982e9b04f13be046d194643ed28aaedd6181f3b (diff)
utility functions: BLI_findptr, BLI_rfindptr --- use for finding an item in a linked list by a pointer.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c9
-rw-r--r--source/blender/editors/interface/resources.c4
-rw-r--r--source/blender/editors/object/object_edit.c12
-rw-r--r--source/blender/editors/object/object_modifier.c9
-rw-r--r--source/blender/editors/object/object_select.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c11
6 files changed, 18 insertions, 35 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index fd98dd83a7d..d98f4891dc5 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1667,14 +1667,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int gpencil_area_exists(bContext *C, ScrArea *sa_test)
{
bScreen *sc = CTX_wm_screen(C);
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa == sa_test)
- return 1;
- }
-
- return 0;
+ return (BLI_findindex(&sc->areabase, sa_test) != -1);
}
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 0ff81f27f6b..20e4360b791 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -643,9 +643,7 @@ void ui_theme_init_default(void)
bTheme *btheme;
/* we search for the theme with name Default */
- for (btheme = U.themes.first; btheme; btheme = btheme->next) {
- if (strcmp("Default", btheme->name) == 0) break;
- }
+ btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
if (btheme == NULL) {
btheme = MEM_callocN(sizeof(bTheme), "theme");
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index b5e85c3712b..aa885320b37 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1720,13 +1720,15 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
{
if (ob != ob_iter) {
- if (type == COPY_PROPERTIES_REPLACE)
+ if (type == COPY_PROPERTIES_REPLACE) {
copy_properties(&ob_iter->prop, &ob->prop);
-
- /* merge - the default when calling with no argument */
- else
- for (prop = ob->prop.first; prop; prop = prop->next)
+ }
+ else {
+ /* merge - the default when calling with no argument */
+ for (prop = ob->prop.first; prop; prop = prop->next) {
set_ob_property(ob_iter, prop);
+ }
+ }
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 47f5a285374..d3b099887cc 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -268,17 +268,12 @@ static int object_modifier_safe_to_delete(Main *bmain, Object *ob,
static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
int *sort_depsgraph)
{
- ModifierData *obmd;
-
/* It seems on rapid delete it is possible to
* get called twice on same modifier, so make
* sure it is in list. */
- for (obmd = ob->modifiers.first; obmd; obmd = obmd->next)
- if (obmd == md)
- break;
-
- if (!obmd)
+ if (BLI_findindex(&ob->modifiers, md) != -1) {
return 0;
+ }
/* special cases */
if (md->type == eModifierType_ParticleSystem) {
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index ff7728d4f68..7eb8cc01db9 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -988,13 +988,11 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "group", group_name);
- for (group = CTX_data_main(C)->group.first; group; group = group->id.next) {
- if (!strcmp(group->id.name, group_name))
- break;
- }
+ group = (Group *)BKE_libblock_find_name(ID_GR, group_name);
- if (!group)
+ if (!group) {
return OPERATOR_PASS_THROUGH;
+ }
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index f327f67be33..c62dc687c73 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -32,6 +32,7 @@
* \ingroup edsculpt
*/
+#include <stddef.h>
#include "MEM_guardedalloc.h"
@@ -379,16 +380,12 @@ static void sculpt_undo_free(ListBase *lb)
SculptUndoNode *sculpt_undo_get_node(PBVHNode *node)
{
ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
- SculptUndoNode *unode;
- if (!lb)
+ if (!lb) {
return NULL;
+ }
- for (unode = lb->first; unode; unode = unode->next)
- if (unode->node == node)
- return unode;
-
- return NULL;
+ return BLI_findptr(lb, node, offsetof(SculptUndoNode, node));
}
static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh,