Cleanup: use value initialization instead of copying default value

Value-initialization has the potential to be more efficient.
Also, the code becomes simpler.
This commit is contained in:
Jacques Lucke 2022-03-29 09:28:46 +02:00
parent d7c6442118
commit 7bd614d431
4 changed files with 6 additions and 6 deletions

View File

@ -489,7 +489,7 @@ void evaluate_constant_field(const GField &field, void *r_value)
{
if (field.node().depends_on_input()) {
const CPPType &type = field.cpp_type();
type.copy_construct(type.default_value(), r_value);
type.value_initialize(r_value);
return;
}

View File

@ -1662,7 +1662,7 @@ class GeometryNodesEvaluator {
void construct_default_value(const CPPType &type, void *r_value)
{
type.copy_construct(type.default_value(), r_value);
type.value_initialize(r_value);
}
NodeState &get_node_state(const DNode node)
@ -1915,7 +1915,7 @@ void NodeParamsProvider::set_default_remaining_outputs()
const CPPType *type = get_socket_cpp_type(socket);
BLI_assert(type != nullptr);
void *buffer = allocator.allocate(type->size(), type->alignment());
type->copy_construct(type->default_value(), buffer);
type->value_initialize(buffer);
evaluator_.forward_output(socket, {type, buffer}, run_state_);
output_state.has_been_computed = true;
}

View File

@ -298,7 +298,7 @@ class RaycastFunction : public fn::MultiFunction {
GMutableSpan result = params.uninitialized_single_output_if_required(7, "Attribute");
if (!result.is_empty()) {
MeshAttributeInterpolator interp(&mesh, hit_mask, hit_positions, hit_indices);
result.type().fill_assign_indices(result.type().default_value(), result.data(), mask);
result.type().value_initialize_indices(result.data(), mask);
interp.sample_data(*target_data_, domain_, get_map_mode(mapping_), result);
}
}

View File

@ -493,7 +493,7 @@ class NearestTransferFunction : public fn::MultiFunction {
GMutableSpan dst = params.uninitialized_single_output_if_required(1, "Attribute");
if (!use_mesh_ && !use_points_) {
dst.type().fill_construct_indices(dst.type().default_value(), dst.data(), mask);
dst.type().value_initialize_indices(dst.data(), mask);
return;
}
@ -673,7 +673,7 @@ class IndexTransferFunction : public fn::MultiFunction {
const CPPType &type = dst.type();
if (src_data_ == nullptr) {
type.fill_construct_indices(type.default_value(), dst.data(), mask);
type.value_initialize_indices(dst.data(), mask);
return;
}