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. See25237d2625
for more info. Similar tocccc6d6905
.
This commit is contained in:
parent
cccc6d6905
commit
4c91c24bc7
Notes:
blender-bot
2023-02-14 08:35:51 +01:00
Referenced by commit 600c069e0e
, Attributes: Correct implementation of typed "write_only" method
|
@ -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};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue