Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-08-31 00:44:47 +0300
committerHans Goudey <h.goudey@me.com>2022-08-31 00:45:00 +0300
commit4c91c24bc7cbe2c4f97be373025a672928a5676d (patch)
tree6472225e425c6d5ba52feff1478bc2e9e04b1a6e
parentcccc6d6905be7ac32cbe8649faf6b17e9c9f636e (diff)
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. See 25237d2625078c6d for more info. Similar to cccc6d6905be7ac.
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index aed55c5db45..0187dbd6f78 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -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};
}