From d138cbfb47e379edc1ee915a8c6ff65b01f000d6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 3 Apr 2020 19:15:01 +0200 Subject: Code Quality: Replace for loops with LISTBASE_FOREACH Note this only changes cases where the variable was declared inside the for loop. To handle it outside as well is a different challenge. Differential Revision: https://developer.blender.org/D7320 --- source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c | 2 +- source/blender/editors/mesh/editmesh_utils.c | 3 +-- source/blender/editors/mesh/meshtools.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/mesh') diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index aa737a1701a..feb6b5aaca9 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -1031,7 +1031,7 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo * could shift because of float precision. * Updates in this case are also redundant. */ bool is_modal = false; - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->state & WM_GIZMO_STATE_MODAL) { is_modal = true; break; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 08976cc46c4..998e0d736e6 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -370,8 +370,7 @@ void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data) * cycles. */ #if 0 - for (Object *other_object = bmain->objects.first; other_object != NULL; - other_object = other_object->id.next) { + for (Object *other_object = bmain->objects.first; other_object != NULL; other_object = other_object->id.next) { if (other_object->data == ob->data) { BKE_object_free_derived_caches(other_object); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 519822dd65c..4a1450eaccc 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -161,7 +161,7 @@ static void join_mesh_single(Depsgraph *depsgraph, */ if (key) { /* if this mesh has any shapekeys, check first, otherwise just copy coordinates */ - for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { /* get pointer to where to write data for this mesh in shapekey's data array */ float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; @@ -191,7 +191,7 @@ static void join_mesh_single(Depsgraph *depsgraph, * - otherwise, copy across plain coordinates (no need to transform coordinates) */ if (key) { - for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { /* get pointer to where to write data for this mesh in shapekey's data array */ float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; @@ -440,7 +440,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } /* Join this object's face maps to the base one's. */ - for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) { + LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) { /* See if this group exists in the object (if it doesn't, add it to the end) */ if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) { bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap"); -- cgit v1.2.3