From dee0b56b9216de8f37589b15be2d21cc1b946773 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Sep 2021 16:08:09 +0200 Subject: Cleanup: simplify resource scope methods Previously, a debug name had to be passed to all methods that added a resource to the `ResourceScope`. The idea was that this would make it easier to find certain bugs. In reality I never found this to be useful, and it was mostly annoying. The thing is, something that is in a resource scope never leaks (unless the resource scope is not destructed of course). Removing the name parameter makes the structure easier to use. --- source/blender/functions/intern/field.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'source/blender/functions/intern') diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc index 574a9e6284f..43f28efd002 100644 --- a/source/blender/functions/intern/field.cc +++ b/source/blender/functions/intern/field.cc @@ -92,7 +92,7 @@ static Vector get_field_context_inputs( if (varray == nullptr) { const CPPType &type = field_input.cpp_type(); varray = &scope.construct( - __func__, type, mask.min_array_size(), type.default_value()); + type, mask.min_array_size(), type.default_value()); } field_context_inputs.append(varray); } @@ -237,8 +237,8 @@ static void build_multi_function_procedure_for_fields(MFProcedure &procedure, if (!already_output_variables.add(variable)) { /* One variable can be output at most once. To output the same value twice, we have to make * a copy first. */ - const MultiFunction ©_fn = scope.construct( - __func__, "copy", variable->data_type()); + const MultiFunction ©_fn = scope.construct("copy", + variable->data_type()); variable = builder.add_call<1>(copy_fn, {variable})[0]; } builder.add_output_parameter(*variable); @@ -381,14 +381,13 @@ Vector evaluate_fields(ResourceScope &scope, buffer = scope.linear_allocator().allocate(type.size() * array_size, type.alignment()); /* Make sure that elements in the buffer will be destructed. */ - PartiallyInitializedArray &destruct_helper = scope.construct( - __func__); + PartiallyInitializedArray &destruct_helper = scope.construct(); destruct_helper.buffer = buffer; destruct_helper.mask = mask; destruct_helper.type = &type; r_varrays[out_index] = &scope.construct( - __func__, GSpan{type, buffer, array_size}); + GSpan{type, buffer, array_size}); } else { /* Write the result into the existing span. */ @@ -427,8 +426,7 @@ Vector evaluate_fields(ResourceScope &scope, void *buffer = scope.linear_allocator().allocate(type.size(), type.alignment()); /* Use this to make sure that the value is destructed in the end. */ - PartiallyInitializedArray &destruct_helper = scope.construct( - __func__); + PartiallyInitializedArray &destruct_helper = scope.construct(); destruct_helper.buffer = buffer; destruct_helper.mask = IndexRange(1); destruct_helper.type = &type; @@ -439,7 +437,7 @@ Vector evaluate_fields(ResourceScope &scope, /* Create virtual array that can be used after the procedure has been executed below. */ const int out_index = constant_field_indices[i]; r_varrays[out_index] = &scope.construct( - __func__, type, array_size, buffer); + type, array_size, buffer); } procedure_executor.call(IndexRange(1), mf_params, mf_context); @@ -608,7 +606,7 @@ int FieldEvaluator::add_with_destination(GField field, GVMutableArray &dst) int FieldEvaluator::add_with_destination(GField field, GMutableSpan dst) { - GVMutableArray &varray = scope_.construct(__func__, dst); + GVMutableArray &varray = scope_.construct(dst); return this->add_with_destination(std::move(field), varray); } @@ -661,7 +659,7 @@ IndexMask FieldEvaluator::get_evaluated_as_mask(const int field_index) return IndexRange(0); } - return scope_.add_value(indices_from_selection(*typed_varray), __func__).as_span(); + return scope_.add_value(indices_from_selection(*typed_varray)).as_span(); } } // namespace blender::fn -- cgit v1.2.3