[Bf-blender-cvs] [4c91c24bc7c] master: Attributes: Avoid unnecessarily initializing new attributes

Hans Goudey noreply at git.blender.org
Tue Aug 30 23:45:37 CEST 2022


Commit: 4c91c24bc7cbe2c4f97be373025a672928a5676d
Author: Hans Goudey
Date:   Tue Aug 30 16:44:47 2022 -0500
Branches: master
https://developer.blender.org/rB4c91c24bc7cbe2c4f97be373025a672928a5676d

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.

===================================================================

M	source/blender/blenkernel/intern/attribute_access.cc

===================================================================

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};
   }



More information about the Bf-blender-cvs mailing list