Commit: d138cbfb47e379edc1ee915a8c6ff65b01f000d6 Author: Dalai Felinto Date: Fri Apr 3 19:15:01 2020 +0200 Branches: master https://developer.blender.org/rBd138cbfb47e379edc1ee915a8c6ff65b01f000d6
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 =================================================================== M source/blender/blenkernel/intern/anim_data.c M source/blender/blenkernel/intern/anim_sys.c M source/blender/blenkernel/intern/armature.c M source/blender/blenkernel/intern/blender.c M source/blender/blenkernel/intern/blender_user_menu.c M source/blender/blenkernel/intern/blendfile.c M source/blender/blenkernel/intern/camera.c M source/blender/blenkernel/intern/collection.c M source/blender/blenkernel/intern/collision.c M source/blender/blenkernel/intern/constraint.c M source/blender/blenkernel/intern/curve.c M source/blender/blenkernel/intern/effect.c M source/blender/blenkernel/intern/fcurve.c M source/blender/blenkernel/intern/fmodifier.c M source/blender/blenkernel/intern/gpencil.c M source/blender/blenkernel/intern/gpencil_geom.c M source/blender/blenkernel/intern/idprop.c M source/blender/blenkernel/intern/idprop_utils.c M source/blender/blenkernel/intern/image.c M source/blender/blenkernel/intern/keyconfig.c M source/blender/blenkernel/intern/layer.c M source/blender/blenkernel/intern/lib_id.c M source/blender/blenkernel/intern/lib_override.c M source/blender/blenkernel/intern/lib_query.c M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/mball.c M source/blender/blenkernel/intern/node.c M source/blender/blenkernel/intern/particle.c M source/blender/blenkernel/intern/pointcache.c M source/blender/blenkernel/intern/scene.c M source/blender/blenkernel/intern/screen.c M source/blender/blenkernel/intern/seqeffects.c M source/blender/blenkernel/intern/sequencer.c M source/blender/blenkernel/intern/text.c M source/blender/blenkernel/intern/texture.c M source/blender/blenkernel/intern/tracking_solver.c M source/blender/blenkernel/intern/undo_system.c M source/blender/blenkernel/intern/workspace.c M source/blender/blenlib/intern/array_store.c M source/blender/blenlib/intern/threads.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/undofile.c M source/blender/blenloader/intern/versioning_270.c M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/versioning_cycles.c M source/blender/blenloader/intern/versioning_defaults.c M source/blender/blenloader/intern/versioning_userdef.c M source/blender/blenloader/intern/writefile.c M source/blender/bmesh/intern/bmesh_marking.c M source/blender/bmesh/intern/bmesh_mesh.c M source/blender/draw/engines/eevee/eevee_materials.c M source/blender/draw/engines/eevee/eevee_volumes.c M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/overlay/overlay_extra.c M source/blender/draw/engines/overlay/overlay_image.c M source/blender/draw/engines/overlay/overlay_motion_path.c M source/blender/draw/engines/workbench/workbench_volume.c M source/blender/draw/intern/draw_cache_impl_curve.c M source/blender/draw/intern/draw_cache_impl_displist.c M source/blender/draw/intern/draw_cache_impl_mesh.c M source/blender/draw/intern/draw_cache_impl_volume.c M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_manager_data.c M source/blender/draw/intern/draw_manager_profiling.c M source/blender/draw/intern/draw_manager_shader.c M source/blender/editors/animation/anim_filter.c M source/blender/editors/animation/anim_markers.c M source/blender/editors/animation/anim_motion_paths.c M source/blender/editors/animation/keyframes_draw.c M source/blender/editors/armature/armature_add.c M source/blender/editors/armature/armature_edit.c M source/blender/editors/armature/armature_naming.c M source/blender/editors/armature/armature_relations.c M source/blender/editors/armature/armature_select.c M source/blender/editors/armature/armature_utils.c M source/blender/editors/armature/editarmature_undo.c M source/blender/editors/armature/pose_select.c M source/blender/editors/armature/pose_transform.c M source/blender/editors/curve/editcurve.c M source/blender/editors/curve/editcurve_select.c M source/blender/editors/gpencil/gpencil_armature.c M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_ops_versioning.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/editors/interface/interface.c M source/blender/editors/interface/interface_eyedropper_gpencil_color.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/interface/interface_query.c M source/blender/editors/interface/interface_region_color_picker.c M source/blender/editors/interface/interface_region_hud.c M source/blender/editors/interface/interface_region_menu_popup.c M source/blender/editors/interface/interface_region_popup.c M source/blender/editors/interface/interface_region_tooltip.c M source/blender/editors/interface/interface_templates.c M source/blender/editors/interface/view2d.c M source/blender/editors/mask/mask_draw.c M source/blender/editors/mask/mask_ops.c M source/blender/editors/mask/mask_relationships.c M source/blender/editors/mask/mask_select.c M source/blender/editors/mask/mask_shapekey.c M source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/mesh/meshtools.c M source/blender/editors/metaball/mball_edit.c M source/blender/editors/object/object_add.c M source/blender/editors/object/object_data_transform.c M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_relations.c M source/blender/editors/object/object_select.c M source/blender/editors/object/object_utils.c M source/blender/editors/object/object_volume.c M source/blender/editors/render/render_internal.c M source/blender/editors/render/render_preview.c M source/blender/editors/render/render_update.c M source/blender/editors/scene/scene_edit.c M source/blender/editors/screen/area.c M source/blender/editors/screen/screen_context.c M source/blender/editors/screen/screen_draw.c M source/blender/editors/screen/screen_edit.c M source/blender/editors/screen/screen_geometry.c M source/blender/editors/screen/screen_ops.c M source/blender/editors/screen/screen_user_menu.c M source/blender/editors/screen/workspace_edit.c M source/blender/editors/screen/workspace_layout_edit.c M source/blender/editors/sculpt_paint/paint_image.c M source/blender/editors/sculpt_paint/paint_ops.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/space_action/action_draw.c M source/blender/editors/space_action/action_select.c M source/blender/editors/space_action/space_action.c M source/blender/editors/space_buttons/space_buttons.c M source/blender/editors/space_clip/clip_editor.c M source/blender/editors/space_image/image_ops.c M source/blender/editors/space_image/image_sequence.c M source/blender/editors/space_image/image_undo.c M source/blender/editors/space_info/info_report.c M source/blender/editors/space_nla/nla_channels.c M source/blender/editors/space_nla/nla_draw.c M source/blender/editors/space_nla/nla_select.c M source/blender/editors/space_node/node_edit.c M source/blender/editors/space_node/node_relationships.c M source/blender/editors/space_node/node_select.c M source/blender/editors/space_outliner/outliner_collections.c M source/blender/editors/space_outliner/outliner_dragdrop.c M source/blender/editors/space_outliner/outliner_draw.c M source/blender/editors/space_outliner/outliner_edit.c M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_outliner/outliner_sync.c M source/blender/editors/space_outliner/outliner_tools.c M source/blender/editors/space_outliner/outliner_tree.c M source/blender/editors/space_outliner/outliner_utils.c M source/blender/editors/space_sequencer/sequencer_edit.c M source/blender/editors/space_sequencer/sequencer_select.c M source/blender/editors/space_view3d/space_view3d.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/editors/space_view3d/view3d_select.c M source/blender/editors/space_view3d/view3d_view.c M source/blender/editors/transform/transform_convert.c M source/blender/editors/transform/transform_convert_armature.c M source/blender/editors/transform/transform_convert_curve.c M source/blender/editors/transform/transform_convert_object.c M source/blender/editors/transform/transform_gizmo_3d.c M source/blender/editors/transform/transform_snap_object.c M source/blender/editors/undo/ed_undo.c M source/blender/editors/util/ed_util.c M source/blender/gpu/intern/gpu_batch_presets.c M source/blender/gpu/intern/gpu_codegen.c M source/blender/gpu/intern/gpu_material.c M source/blender/gpu/intern/gpu_node_graph.c M source/blender/gpu/intern/gpu_select_pick.c M source/blender/gpu/intern/gpu_uniformbuffer.c M source/blender/gpu/intern/gpu_viewport.c M source/blender/ikplugin/intern/iksolver_plugin.c M source/blender/makesrna/intern/rna_access_compare_override.c M source/blender/makesrna/intern/rna_key.c M source/blender/makesrna/intern/rna_layer.c M source/blender/makesrna/intern/rna_particle.c M source/blender/makesrna/intern/rna_scene.c M source/blender/makesrna/intern/rna_space.c M source/blender/makesrna/intern/rna_ui.c M source/blender/makesrna/intern/rna_wm_gizmo.c M source/blender/modifiers/intern/MOD_dynamicpaint.c M source/blender/nodes/shader/node_shader_tree.c M source/blender/nodes/shader/nodes/node_shader_displacement.c M source/blender/nodes/shader/nodes/node_shader_tex_brick.c M source/blender/nodes/shader/nodes/node_shader_volume_principled.c M source/blender/python/intern/bpy_capi_utils.c M source/blender/render/intern/source/pipeline.c M source/blender/render/intern/source/render_result.c M source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c M source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c M source/blender/windowmanager/intern/wm_dragdrop.c M source/blender/windowmanager/intern/wm_draw.c M source/blender/windowmanager/intern/wm_event_system.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_jobs.c M source/blender/windowmanager/intern/wm_keymap.c M source/blender/windowmanager/intern/wm_keymap_utils.c M source/blender/windowmanager/intern/wm_operators.c M source/blender/windowmanager/intern/wm_surface.c M source/blender/windowmanager/intern/wm_toolsystem.c M source/blender/windowmanager/intern/wm_window.c M source/blender/windowmanager/message_bus/intern/wm_message_bus.c =================================================================== diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index cd56796c3cf..41bfc5b59e4 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -1130,7 +1130,7 @@ bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix) /* free drivers - stored as a list of F-Curves */ any_removed |= fcurves_path_remove_fix(prefix, &adt->drivers); /* NLA Data - Animation Data for Strips */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { any_removed |= nlastrips_path_remove_fix(prefix, &nlt->strips); } } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 69efac37fbf..18320ef0f8d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -542,7 +542,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr, bool flush_to_original) { /* Calculate then execute each curve. */ - for (FCurve *fcu = list->first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, list) { /* Check if this F-Curve doesn't belong to a muted group. */ if ((fcu->grp != NULL) && (fcu->grp->flag & AGRP_MUTED)) { continue; @@ -1095,7 +1095,7 @@ static void nlaeval_free(NlaEvalData *nlaeval) nlaeval_snapshot_free_data(&nlaeval->eval_snapshot); /* Delete channels. */ - for (NlaEvalChannel *nec = nlaeval->channels.first; nec; nec = nec->next) { + LISTBASE_FOREACH (NlaEvalChannel *, nec, &nlaeval->channels) { nlaevalchan_free_data(nec); } @@ -1954,7 +1954,7 @@ void nladata_flush_channels(PointerRNA *ptr, } /* for each channel with accumulated values, write its value on the property it affects */ - for (NlaEvalChannel *nec = channels->channels.first; nec; nec = nec->next) { + LISTBASE_FOREACH (NlaEvalChannel *, nec, &channels->channels) { NlaEvalChannelSnapshot *nec_snapshot = nlaeval_snapshot_find_channel(snapshot, nec); PathResolvedRNA rna = {nec->key.ptr, nec->key.prop, -1}; @@ -1985,7 +1985,7 @@ static void nla_eval_domain_action(PointerRNA *ptr, return; } - for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, &act->curves) { /* check if this curve should be skipped */ if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) { continue; @@ -2020,7 +2020,7 @@ static void nla_eval_domain_strips(PointerRNA *ptr, ListBase *strips, GSet *touched_actions) { - for (NlaStrip *strip = strips->first; strip; strip = strip->next) { + LISTBASE_FOREACH (NlaStrip *, strip, strips) { /* check strip's action */ if (strip->act) { nla_eval_domain_action(ptr, channels, strip->act, touched_actions); @@ -2044,7 +2044,7 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels, } /* NLA Data - Animation Data for Strips */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { /* solo and muting are mutually exclusive... */ if (adt->flag & ADT_NLA_SOLO_TRACK) { /* skip if there is a solo track, but this isn't it */ @@ -2430,7 +2430,7 @@ bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, */ void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache) { - for (NlaKeyframingContext *ctx = cache->first; ctx; ctx = ctx->next) { + LISTBASE_FOREACH (NlaKeyframingContext *, ctx, cache) { MEM_SAFE_FREE(ctx->eval_strip); nlaeval_free(&ctx->nla_channels); } @@ -2738,7 +2738,7 @@ void BKE_animsys_update_driver_array(ID *id) adt->driver_array = MEM_mallocN(sizeof(FCurve *) * num_drivers, "adt->driver_array"); int driver_index = 0; - for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) { adt->driver_array[driver_index++] = fcu; } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b8d0f8c8c92..daf364432f4 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -190,7 +190,7 @@ bArmature *BKE_armature_from_object(Object *ob) int BKE_armature_bonelist_count(ListBase *lb) { int i = 0; - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { i += 1 + BKE_armature_bonelist_count(&bone->childbase); } @@ -303,7 +303,7 @@ static void armature_transform_recurse(ListBase *bonebase, const Bone *bone_parent, const float arm_mat_parent_inv[4][4]) { - for (Bone *bone = bonebase->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, bonebase) { /* Store the initial bone roll in a matrix, this is needed even for child bones * so any change in head/tail doesn't cause the roll to change. @@ -424,7 +424,7 @@ Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name) static void armature_bone_from_name_insert_recursive(GHash *bone_hash, ListBase *lb) { - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { BLI_ghash_insert(bone_hash, bone->name, bone); armature_bone_from_name_insert_recursive(bone_hash, &bone->childbase); } @@ -474,7 +474,7 @@ bool BKE_armature_bone_flag_test_recursive(const Bone *bone, int flag) static void armature_refresh_layer_used_recursive(bArmature *arm, ListBase *bones) { - for (Bone *bone = bones->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, bones) { arm->layer_used |= bone->layer; armature_refresh_layer_used_recursive(arm, &bone->childbase); } @@ -2701,7 +2701,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int */ void BKE_pose_clear_pointers(bPose *pose) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { pchan->bone = NULL; pchan->child = NULL; } @@ -2709,7 +2709,7 @@ void BKE_pose_clear_pointers(bPose *pose) void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { pchan->bone = BKE_armature_find_bone_name(armature, pchan->name); } } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 70ab52828f2..b3a4de02451 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -182,7 +182,7 @@ static void userdef_free_keymaps(UserDef *userdef) { for (wmKeyMap *km = userdef->user_keymaps.first, *km_next; km; km = km_next) { km_next = km->next; - for (wmKeyMapDiffItem *kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { + LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) { if (kmdi->add_item) { keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); @@ -193,7 +193,7 @@ static void userdef_free_keymaps(UserDef *userdef) } } - for (wmKeyMapItem *kmi = km->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) { keymap_item_free(kmi); } @@ -250,7 +250,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) userdef_free_addons(userdef); if (clear_fonts) { - for (uiFont *font = userdef->uifonts.first; font; font = font->next) { + LISTBASE_FOREACH (uiFont *, font, &userdef->uifonts) { BLF_unload_id(font->blf_id); } BLF_default_set(-1); diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c index ad34ef03e04..edd89357fd5 100644 --- a/source/blender/blenkernel/intern/blender_user_menu.c +++ b/source/blender/blenkernel/intern/blender_user_menu.c @@ -38,7 +38,7 @@ bUserMenu *BKE_blender_user_menu_find(ListBase *lb, char space_type, const char *context) { - for (bUserMenu *um = lb->first; um; um = um->next) { + LISTBASE_FOREACH (bUserMenu *, um, lb) { if ((space_type == um->space_type) && (STREQ(context, um->context))) { return um; } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 6bf47a8c280..d862132480a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -345,7 +345,7 @@ static void setup_app_data(bContext *C, wmWindowManager *wm = bmain->wm.first; if (wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->scene && win->scene != curscene) { BKE_scene_set_background(bmain, win->scene); } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 323bb597127..71a2b6f703a 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -912,7 +912,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con name[0] = '\0'; /* we need to take the better match, thus the len_suffix_max test */ - for (const SceneRenderView *srv = scene->r.views.first; srv; srv = srv->next) { + LISTBASE_FOREACH (const SceneRenderView *, srv, &scene->r.views) { const int len_suffix = strlen(srv->suffix); if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) { diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index d39df4cc6a3..83a6949430e 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -106,10 +106,10 @@ static void collection_copy_da @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
