Curves: Avoid unnecessary allocation when calculating offsets

Arrays for curve handle types were allocated even when there were no
Bezier curves. This saves 0.5ms of the total 0.9ms spent creating the
evaluated curve offsets, which happens every time the topology
of non-poly curves change.
This commit is contained in:
Hans Goudey
2023-02-21 22:32:36 -05:00
parent 05637254da
commit 612965497e

View File

@@ -469,8 +469,12 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves,
const VArray<int> resolution = curves.resolution();
const VArray<bool> cyclic = curves.cyclic();
const VArraySpan<int8_t> handle_types_left{curves.handle_types_left()};
const VArraySpan<int8_t> handle_types_right{curves.handle_types_right()};
VArraySpan<int8_t> handle_types_left;
VArraySpan<int8_t> handle_types_right;
if (curves.has_curve_with_type(CURVE_TYPE_BEZIER)) {
handle_types_left = curves.handle_types_left();
handle_types_right = curves.handle_types_right();
}
const VArray<int8_t> nurbs_orders = curves.nurbs_orders();
const VArray<int8_t> nurbs_knots_modes = curves.nurbs_knots_modes();