Curves: Avoid building evaluated point offsets for poly curves

When all the curves are poly curves, skip the work of building a
separate array of offsets for the evaluated points (which are the
same as the control points). This saves 1-4ms on every reevaluation
in test files with many curves.
This commit is contained in:
Hans Goudey 2023-01-19 15:22:54 -06:00
parent 9233b609eb
commit 8d63293c46
1 changed files with 8 additions and 0 deletions

View File

@ -499,6 +499,14 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves,
OffsetIndices<int> CurvesGeometry::evaluated_points_by_curve() const
{
if (this->is_single_type(CURVE_TYPE_POLY)) {
/* When all the curves are poly curves, the evaluated offsets are the same as the control
* point offsets, so it's possible to completely avoid building a new offsets array. */
this->runtime->offsets_cache_mutex.ensure(
[&]() { this->runtime->evaluated_offsets_cache.clear_and_shrink(); });
return this->points_by_curve();
}
this->runtime->offsets_cache_mutex.ensure([&]() {
this->runtime->evaluated_offsets_cache.resize(this->curves_num() + 1);