no need to allocate these on the heap

Change-Id: I02ec48ba369e91afc67246f9cdf18f88b24af49f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160837
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2023-12-15 21:12:41 +02:00 committed by Noel Grandin
parent 23f8c47866
commit 73e5161bae

View file

@ -24,6 +24,7 @@
#include <vector>
#include <algorithm>
#include <memory>
#include <optional>
#include <cmath>
#include <limits>
@ -569,8 +570,8 @@ void SplineCalculater::CalculateCubicSplines(
// generate a spline for each coordinate. It holds the complete
// information to calculate each point of the curve
std::unique_ptr<lcl_SplineCalculation> aSplineX;
std::unique_ptr<lcl_SplineCalculation> aSplineY;
std::optional<lcl_SplineCalculation> aSplineX;
std::optional<lcl_SplineCalculation> aSplineY;
// lcl_SplineCalculation* aSplineZ; the z-coordinates of all points in
// a data series are equal. No spline calculation needed, but copy
// coordinate to output
@ -580,15 +581,15 @@ void SplineCalculater::CalculateCubicSplines(
pOld[ 0 ].PositionZ == pOld[nMaxIndexPoints].PositionZ &&
nMaxIndexPoints >=2 )
{ // periodic spline
aSplineX = std::make_unique<lcl_SplineCalculation>(std::move(aInputX));
aSplineY = std::make_unique<lcl_SplineCalculation>(std::move(aInputY));
aSplineX.emplace(std::move(aInputX));
aSplineY.emplace(std::move(aInputY));
}
else // generate the kind "natural spline"
{
double fXDerivation = std::numeric_limits<double>::infinity();
double fYDerivation = std::numeric_limits<double>::infinity();
aSplineX = std::make_unique<lcl_SplineCalculation>(std::move(aInputX), fXDerivation, fXDerivation);
aSplineY = std::make_unique<lcl_SplineCalculation>(std::move(aInputY), fYDerivation, fYDerivation);
aSplineX.emplace(std::move(aInputX), fXDerivation, fXDerivation);
aSplineY.emplace(std::move(aInputY), fYDerivation, fYDerivation);
}
// fill result polygon with calculated values