Curves: Use early out when apapting domain of single value

When adapting the domain of a single value virtual array, skip
allocating an array for the result and just return another single
value. Among other cases, this can help when everything is selected
in sculpt mode, moving domain interpolation from 5% of perf samples
to 0% when sculpting.
This commit is contained in:
Hans Goudey 2022-09-23 16:43:42 -05:00
parent c25df02ac3
commit 535f50e5a6
1 changed files with 5 additions and 0 deletions

View File

@ -1558,6 +1558,11 @@ GVArray CurvesGeometry::adapt_domain(const GVArray &varray,
if (from == to) {
return varray;
}
if (varray.is_single()) {
BUFFER_FOR_CPP_TYPE_VALUE(varray.type(), value);
varray.get_internal_single(value);
return GVArray::ForSingle(varray.type(), this->attributes().domain_size(to), value);
}
if (from == ATTR_DOMAIN_POINT && to == ATTR_DOMAIN_CURVE) {
return adapt_curve_domain_point_to_curve(*this, varray);