From 612965497e8bb8dfee718d06bc2edfc0b2cdfaab Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 21 Feb 2023 22:32:36 -0500 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/curves_geometry.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 704bbb34f49..ee438cdf5bf 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -469,8 +469,12 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves, const VArray resolution = curves.resolution(); const VArray cyclic = curves.cyclic(); - const VArraySpan handle_types_left{curves.handle_types_left()}; - const VArraySpan handle_types_right{curves.handle_types_right()}; + VArraySpan handle_types_left; + VArraySpan 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 nurbs_orders = curves.nurbs_orders(); const VArray nurbs_knots_modes = curves.nurbs_knots_modes();