From 52ce8d408f30c9bc369df3e98d26bbb28fd06366 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Apr 2024 10:55:10 +1100 Subject: [PATCH] Cleanup: use const arguments & variables --- .../guardedalloc/intern/mallocn_lockfree_impl.c | 16 ++++++++-------- source/blender/blenkernel/BKE_addon.h | 2 +- source/blender/blenkernel/BKE_armature.hh | 6 +++--- source/blender/blenkernel/intern/addon.cc | 2 +- .../blender/blenkernel/intern/armature_pose.cc | 10 +++++----- .../blender/blenkernel/intern/pbvh_uv_islands.cc | 2 +- source/blender/blenkernel/intern/subdiv_ccg.cc | 8 ++++---- source/blender/blenlib/intern/mesh_boolean.cc | 2 +- source/blender/blenlib/intern/scanfill.c | 2 +- .../intern/ocio_color_space_conversion_shader.cc | 6 +++--- .../draw/engines/eevee_next/eevee_velocity.cc | 6 +++--- .../editors/asset/intern/asset_indexer.cc | 2 +- source/blender/editors/space_clip/clip_ops.cc | 2 +- .../space_sequencer/sequencer_retiming.cc | 2 +- .../transform/transform_snap_animation.cc | 2 +- source/blender/sequencer/intern/iterator.cc | 2 +- source/blender/sequencer/intern/modifier.cc | 12 ++++++------ 17 files changed, 42 insertions(+), 42 deletions(-) diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c index c7ebc9b5a96..e5c2ca5e916 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c @@ -115,10 +115,10 @@ void *MEM_lockfree_dupallocN(const void *vmemh) { void *newp = NULL; if (vmemh) { - MemHead *memh = MEMHEAD_FROM_PTR(vmemh); + const MemHead *memh = MEMHEAD_FROM_PTR(vmemh); const size_t prev_size = MEM_lockfree_allocN_len(vmemh); if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) { - MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); + const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); newp = MEM_lockfree_mallocN_aligned( prev_size, (size_t)memh_aligned->alignment, "dupli_malloc"); } @@ -135,14 +135,14 @@ void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str) void *newp = NULL; if (vmemh) { - MemHead *memh = MEMHEAD_FROM_PTR(vmemh); - size_t old_len = MEM_lockfree_allocN_len(vmemh); + const MemHead *memh = MEMHEAD_FROM_PTR(vmemh); + const size_t old_len = MEM_lockfree_allocN_len(vmemh); if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) { newp = MEM_lockfree_mallocN(len, "realloc"); } else { - MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); + const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "realloc"); } @@ -171,14 +171,14 @@ void *MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str) void *newp = NULL; if (vmemh) { - MemHead *memh = MEMHEAD_FROM_PTR(vmemh); - size_t old_len = MEM_lockfree_allocN_len(vmemh); + const MemHead *memh = MEMHEAD_FROM_PTR(vmemh); + const size_t old_len = MEM_lockfree_allocN_len(vmemh); if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) { newp = MEM_lockfree_mallocN(len, "recalloc"); } else { - MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); + const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "recalloc"); } diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h index e9664fdbd79..e03779460d2 100644 --- a/source/blender/blenkernel/BKE_addon.h +++ b/source/blender/blenkernel/BKE_addon.h @@ -35,7 +35,7 @@ void BKE_addon_pref_type_init(void); void BKE_addon_pref_type_free(void); struct bAddon *BKE_addon_new(void); -struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module); +struct bAddon *BKE_addon_find(const struct ListBase *addon_list, const char *module); struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module); bool BKE_addon_remove_safe(struct ListBase *addon_list, const char *module); void BKE_addon_free(struct bAddon *addon); diff --git a/source/blender/blenkernel/BKE_armature.hh b/source/blender/blenkernel/BKE_armature.hh index 35511f563ad..5e3e0558de1 100644 --- a/source/blender/blenkernel/BKE_armature.hh +++ b/source/blender/blenkernel/BKE_armature.hh @@ -280,17 +280,17 @@ void BKE_pose_where_is_bone_tail(bPoseChannel *pchan); */ void BKE_pose_apply_action_selected_bones(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context); + const AnimationEvalContext *anim_eval_context); /** * Evaluate the action and apply it to the pose. Ignore selection state of the bones. */ void BKE_pose_apply_action_all_bones(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context); + const AnimationEvalContext *anim_eval_context); void BKE_pose_apply_action_blend(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context, + const AnimationEvalContext *anim_eval_context, float blend_factor); void vec_roll_to_mat3(const float vec[3], float roll, float r_mat[3][3]); diff --git a/source/blender/blenkernel/intern/addon.cc b/source/blender/blenkernel/intern/addon.cc index ade16029ebd..951db8e6765 100644 --- a/source/blender/blenkernel/intern/addon.cc +++ b/source/blender/blenkernel/intern/addon.cc @@ -38,7 +38,7 @@ bAddon *BKE_addon_new() return addon; } -bAddon *BKE_addon_find(ListBase *addon_list, const char *module) +bAddon *BKE_addon_find(const ListBase *addon_list, const char *module) { return static_cast(BLI_findstring(addon_list, module, offsetof(bAddon, module))); } diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc index 2a481260f56..fa8fca4ecc3 100644 --- a/source/blender/blenkernel/intern/armature_pose.cc +++ b/source/blender/blenkernel/intern/armature_pose.cc @@ -34,14 +34,14 @@ void pose_apply_restore_fcurves(bAction *action); void pose_apply(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context, + const AnimationEvalContext *anim_eval_context, ActionApplier applier); } // namespace void BKE_pose_apply_action_selected_bones(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context) + const AnimationEvalContext *anim_eval_context) { auto evaluate_and_apply = [](PointerRNA *ptr, bAction *act, const AnimationEvalContext *anim_eval_context) { @@ -53,7 +53,7 @@ void BKE_pose_apply_action_selected_bones(Object *ob, void BKE_pose_apply_action_all_bones(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context) + const AnimationEvalContext *anim_eval_context) { PointerRNA pose_owner_ptr = RNA_id_pointer_create(&ob->id); animsys_evaluate_action(&pose_owner_ptr, action, anim_eval_context, false); @@ -61,7 +61,7 @@ void BKE_pose_apply_action_all_bones(Object *ob, void BKE_pose_apply_action_blend(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context, + const AnimationEvalContext *anim_eval_context, const float blend_factor) { auto evaluate_and_blend = [blend_factor](PointerRNA *ptr, @@ -76,7 +76,7 @@ void BKE_pose_apply_action_blend(Object *ob, namespace { void pose_apply(Object *ob, bAction *action, - AnimationEvalContext *anim_eval_context, + const AnimationEvalContext *anim_eval_context, ActionApplier applier) { bPose *pose = ob->pose; diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 85e57f77157..09c3e07f9b4 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -312,7 +312,7 @@ UVVertex *UVEdge::get_other_uv_vertex(const int vertex) UVVertex *UVIsland::lookup(const UVVertex &vertex) { const int vert_index = vertex.vertex; - Vector &vertices = uv_vertex_lookup.lookup_or_add_default(vert_index); + const Vector &vertices = uv_vertex_lookup.lookup_or_add_default(vert_index); for (UVVertex *v : vertices) { if (v->uv == vertex.uv) { return v; diff --git a/source/blender/blenkernel/intern/subdiv_ccg.cc b/source/blender/blenkernel/intern/subdiv_ccg.cc index 38332dcff67..cb2b71209a3 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.cc +++ b/source/blender/blenkernel/intern/subdiv_ccg.cc @@ -560,7 +560,7 @@ CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg) * {(x, y), {x + 1, y}, {x + 1, y + 1}, {x, y + 1}} * * The result is stored in normals storage from TLS. */ -static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG &subdiv_ccg, +static void subdiv_ccg_recalc_inner_face_normals(const SubdivCCG &subdiv_ccg, const CCGKey &key, MutableSpan face_normals, const int corner) @@ -590,7 +590,7 @@ static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG &subdiv_ccg, } /* Average normals at every grid element, using adjacent faces normals. */ -static void subdiv_ccg_average_inner_face_normals(SubdivCCG &subdiv_ccg, +static void subdiv_ccg_average_inner_face_normals(const SubdivCCG &subdiv_ccg, const CCGKey &key, const Span face_normals, const int corner) @@ -690,7 +690,7 @@ static void average_grid_element_value_v3(float a[3], float b[3]) copy_v3_v3(b, a); } -static void average_grid_element(SubdivCCG &subdiv_ccg, +static void average_grid_element(const SubdivCCG &subdiv_ccg, const CCGKey &key, CCGElem *grid_element_a, CCGElem *grid_element_b) @@ -744,7 +744,7 @@ static void element_accumulator_mul_fl(GridElementAccumulator &accumulator, cons accumulator.mask *= f; } -static void element_accumulator_copy(SubdivCCG &subdiv_ccg, +static void element_accumulator_copy(const SubdivCCG &subdiv_ccg, const CCGKey &key, CCGElem &destination, const GridElementAccumulator &accumulator) diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc index 68ecb161928..941bbac9145 100644 --- a/source/blender/blenlib/intern/mesh_boolean.cc +++ b/source/blender/blenlib/intern/mesh_boolean.cc @@ -2705,7 +2705,7 @@ static bool raycast_test_remove(BoolOpType op, Array &winding, int shape, b } /** Add triangle a flipped version of tri to out_faces. */ -static void raycast_add_flipped(Vector &out_faces, Face &tri, IMeshArena *arena) +static void raycast_add_flipped(Vector &out_faces, const Face &tri, IMeshArena *arena) { Array flipped_vs = {tri[0], tri[2], tri[1]}; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 3308d76de73..ad8a99e5fe7 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -348,7 +348,7 @@ static ScanFillVertLink *addedgetoscanlist(ScanFillVertLink *scdata, ScanFillEdg /** * Return true if `eve` inside the bound-box of `eed`. */ -static bool boundinsideEV(ScanFillEdge *eed, ScanFillVert *eve) +static bool boundinsideEV(const ScanFillEdge *eed, const ScanFillVert *eve) { float minx, maxx, miny, maxy; diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc index 254ecc73729..17f0a674bcd 100644 --- a/source/blender/compositor/realtime_compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc @@ -139,7 +139,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { /* Don't use the name argument directly since ShaderCreateInfo only stores references to * resource names, instead, use the name that is stored in resource_names_. */ - std::string &resource_name = *resource_names_[resource_names_.size() - 1]; + const std::string &resource_name = *resource_names_[resource_names_.size() - 1]; shader_create_info_.push_constant(Type::BOOL, resource_name); boolean_uniforms_.add(name, get_bool); @@ -228,7 +228,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { /* Don't use the name argument directly since ShaderCreateInfo only stores references to * resource names, instead, use the name that is stored in resource_names_. */ - std::string &resource_name = *resource_names_[resource_names_.size() - 1]; + const std::string &resource_name = *resource_names_[resource_names_.size() - 1]; GPUTexture *texture; const ResultType result_type = (channel == TEXTURE_RGB_CHANNEL) ? ResultType::Float3 : @@ -267,7 +267,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { /* Don't use the name argument directly since ShaderCreateInfo only stores references to * resource names, instead, use the name that is stored in resource_names_. */ - std::string &resource_name = *resource_names_[resource_names_.size() - 1]; + const std::string &resource_name = *resource_names_[resource_names_.size() - 1]; shader_create_info_.sampler(textures_.size() + 1, ImageType::FLOAT_3D, resource_name); GPUTexture *texture = GPU_texture_create_3d( diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index b1d25d9d8ea..c69816e15e0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -209,9 +209,9 @@ bool VelocityModule::step_object_sync(Object *ob, /* Avoid drawing object that has no motions but were tagged as such. */ if (step_ == STEP_CURRENT && has_motion == true && has_deform == false) { - float4x4 &obmat_curr = (*object_steps[STEP_CURRENT])[vel.obj.ofs[STEP_CURRENT]]; - float4x4 &obmat_prev = (*object_steps[STEP_PREVIOUS])[vel.obj.ofs[STEP_PREVIOUS]]; - float4x4 &obmat_next = (*object_steps[STEP_NEXT])[vel.obj.ofs[STEP_NEXT]]; + const float4x4 &obmat_curr = (*object_steps[STEP_CURRENT])[vel.obj.ofs[STEP_CURRENT]]; + const float4x4 &obmat_prev = (*object_steps[STEP_PREVIOUS])[vel.obj.ofs[STEP_PREVIOUS]]; + const float4x4 &obmat_next = (*object_steps[STEP_NEXT])[vel.obj.ofs[STEP_NEXT]]; if (inst_.is_viewport()) { has_motion = (obmat_curr != obmat_prev); } diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index 02d5e31c82a..e8e090acc98 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -547,7 +547,7 @@ class AssetIndexFile : public AbstractFile { /** * Returns whether the index file is older than the given asset file. */ - bool is_older_than(BlendFile &asset_file) const + bool is_older_than(const BlendFile &asset_file) const { return BLI_file_older(this->get_file_path(), asset_file.get_file_path()); } diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index 573219aac62..3956560b7b6 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -1216,7 +1216,7 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto static void do_movie_proxy(void *pjv, int * /*build_sizes*/, int /*build_count*/, - int *build_undistort_sizes, + const int *build_undistort_sizes, int build_undistort_count, bool *stop, bool *do_update, diff --git a/source/blender/editors/space_sequencer/sequencer_retiming.cc b/source/blender/editors/space_sequencer/sequencer_retiming.cc index 88b99f3260f..e3b506018cd 100644 --- a/source/blender/editors/space_sequencer/sequencer_retiming.cc +++ b/source/blender/editors/space_sequencer/sequencer_retiming.cc @@ -769,7 +769,7 @@ int sequencer_retiming_key_select_exec(bContext *C, wmOperator *op) return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static void realize_fake_keys_in_rect(bContext *C, Sequence *seq, rctf &rectf) +static void realize_fake_keys_in_rect(bContext *C, Sequence *seq, const rctf &rectf) { const Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/transform/transform_snap_animation.cc b/source/blender/editors/transform/transform_snap_animation.cc index 1e3a57e5097..c45a85eca8f 100644 --- a/source/blender/editors/transform/transform_snap_animation.cc +++ b/source/blender/editors/transform/transform_snap_animation.cc @@ -117,7 +117,7 @@ static void invert_snap(eSnapMode &snap_mode) /* WORKAROUND: The source position is based on the transformed elements. * However, at this stage, the transformation has not yet been applied. * So apply the transformation here. */ -static float2 nla_transform_apply(TransInfo *t, const float *vec, float2 &ival) +static float2 nla_transform_apply(TransInfo *t, const float *vec, const float2 &ival) { float4x4 mat = float4x4::identity(); diff --git a/source/blender/sequencer/intern/iterator.cc b/source/blender/sequencer/intern/iterator.cc index 447684d389d..f4167bf7aac 100644 --- a/source/blender/sequencer/intern/iterator.cc +++ b/source/blender/sequencer/intern/iterator.cc @@ -152,7 +152,7 @@ static void collection_filter_channel_up_to_incl(VectorSet &strips, /* Check if seq must be rendered. This depends on whole stack in some cases, not only seq itself. * Order of applying these conditions is important. */ -static bool must_render_strip(VectorSet &strips, Sequence *strip) +static bool must_render_strip(const VectorSet &strips, Sequence *strip) { bool seq_have_effect_in_stack = false; for (Sequence *strip_iter : strips) { diff --git a/source/blender/sequencer/intern/modifier.cc b/source/blender/sequencer/intern/modifier.cc index 07f353b5f76..668c03c36e1 100644 --- a/source/blender/sequencer/intern/modifier.cc +++ b/source/blender/sequencer/intern/modifier.cc @@ -346,12 +346,12 @@ static void make_cb_table_float_sop( } static void color_balance_byte_byte( - StripColorBalance *cb_, uchar *rect, uchar *mask_rect, int width, int height, float mul) + StripColorBalance *cb_, uchar *rect, const uchar *mask_rect, int width, int height, float mul) { // uchar cb_tab[3][256]; uchar *cp = rect; uchar *e = cp + width * 4 * height; - uchar *m = mask_rect; + const uchar *m = mask_rect; StripColorBalance cb = calc_cb(cb_); @@ -392,7 +392,7 @@ static void color_balance_byte_byte( static void color_balance_byte_float(StripColorBalance *cb_, uchar *rect, float *rect_float, - uchar *mask_rect, + const uchar *mask_rect, int width, int height, float mul) @@ -401,7 +401,7 @@ static void color_balance_byte_float(StripColorBalance *cb_, int c, i; uchar *p = rect; uchar *e = p + width * 4 * height; - uchar *m = mask_rect; + const uchar *m = mask_rect; float *o; StripColorBalance cb; @@ -552,9 +552,9 @@ static void *color_balance_do_thread(void *thread_data_v) StripColorBalance *cb = thread_data->cb; int width = thread_data->width, height = thread_data->height; uchar *rect = thread_data->rect; - uchar *mask_rect = thread_data->mask_rect; + const uchar *mask_rect = thread_data->mask_rect; float *rect_float = thread_data->rect_float; - float *mask_rect_float = thread_data->mask_rect_float; + const float *mask_rect_float = thread_data->mask_rect_float; float mul = thread_data->mul; if (rect_float) {