Attributes: Avoid unnecessarily initializing new attributes
The "write_only" (i.e. no reading) API function expects the caller to set values for all new attribute elements, so using calloc or setting the default value first is redundant. In theory this can improve performance by avoiding an extra pass over the array. I observed a 6% improvement in a basic test with the mesh to points node: from 47.9ms to 45ms on average. See25237d2625for more info. Similar tocccc6d6905.
This commit is contained in:
@@ -966,7 +966,8 @@ GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_span(
|
||||
GSpanAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write_only_span(
|
||||
const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
|
||||
{
|
||||
GAttributeWriter attribute = this->lookup_or_add_for_write(attribute_id, domain, data_type);
|
||||
GAttributeWriter attribute = this->lookup_or_add_for_write(
|
||||
attribute_id, domain, data_type, AttributeInitConstruct());
|
||||
if (attribute) {
|
||||
return GSpanAttributeWriter{std::move(attribute), false};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user