diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-13 12:15:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-18 08:30:56 +0100 |
commit | 7a46f18d30285c7632eac70bedcb9f339c3aaa9c (patch) | |
tree | a22326bb22db936d710e3143f302021ade6bf095 | |
parent | 6dc36d343aeacb3d1e14ec0c847937d63f4e68a7 (diff) |
no need to allocate sc::op::Op on the heap here
Change-Id: I6a048a51eacaa7063318cdc27d5bc25cc96d557b
Reviewed-on: https://gerrit.libreoffice.org/65304
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/inc/matrixoperators.hxx | 8 | ||||
-rw-r--r-- | sc/inc/scmatrix.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/matrixoperators.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 20 |
5 files changed, 21 insertions, 21 deletions
diff --git a/sc/inc/matrixoperators.hxx b/sc/inc/matrixoperators.hxx index 25ecf63331f6..cadf5541b778 100644 --- a/sc/inc/matrixoperators.hxx +++ b/sc/inc/matrixoperators.hxx @@ -25,7 +25,7 @@ struct Op_ mInitVal(InitVal), maOp(aOp) { } - void operator()(double& rAccum, double fVal) + void operator()(double& rAccum, double fVal) const { maOp(rAccum, fVal); } @@ -36,19 +36,19 @@ using Op = Op_<std::function<void(double&, double)>>; struct Sum { static const double InitVal; - void operator()(double& rAccum, double fVal); + void operator()(double& rAccum, double fVal) const; }; struct SumSquare { static const double InitVal; - void operator()(double& rAccum, double fVal); + void operator()(double& rAccum, double fVal) const; }; struct Product { static const double InitVal; - void operator()(double& rAccum, double fVal); + void operator()(double& rAccum, double fVal) const; }; } diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index cb6f170cfcce..2538ac2d4c27 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -399,7 +399,7 @@ public: void DivOp(bool bFlag, double fVal, ScMatrix& rMat) ; void PowOp(bool bFlag, double fVal, ScMatrix& rMat) ; - std::vector<ScMatrix::IterateResult> Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp) ; + std::vector<ScMatrix::IterateResult> Collect(const std::vector<sc::op::Op>& aOp) ; void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos, DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc, diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 2d7a8bafec5b..1015d8cfc78a 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -2745,9 +2745,9 @@ void ScInterpreter::ScFTest() double fSum2 = 0.0; double fSumSqr2 = 0.0; - std::vector<std::unique_ptr<sc::op::Op>> aOp; - aOp.emplace_back(new sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal;})); - aOp.emplace_back(new sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal * fVal;})); + std::vector<sc::op::Op> aOp; + aOp.emplace_back(sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal;})); + aOp.emplace_back(sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal * fVal;})); auto aVal1 = pMat1->Collect(aOp); fSum1 = aVal1[0].mfFirst + aVal1[0].mfRest; diff --git a/sc/source/core/tool/matrixoperators.cxx b/sc/source/core/tool/matrixoperators.cxx index d9b1c116f465..cc2d2d9bbf89 100644 --- a/sc/source/core/tool/matrixoperators.cxx +++ b/sc/source/core/tool/matrixoperators.cxx @@ -15,21 +15,21 @@ namespace sc { namespace op { -void Sum::operator()(double& rAccum, double fVal) +void Sum::operator()(double& rAccum, double fVal) const { rAccum += fVal; } const double Sum::InitVal = 0.0; -void SumSquare::operator()(double& rAccum, double fVal) +void SumSquare::operator()(double& rAccum, double fVal) const { rAccum += fVal * fVal; } const double SumSquare::InitVal = 0.0; -void Product::operator()(double& rAccum, double fVal) +void Product::operator()(double& rAccum, double fVal) const { rAccum *= fVal; } diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 59231e7fcb62..8b3c8ffd5407 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -330,7 +330,7 @@ public: const ScMatrix::EmptyOpFunction& aEmptyFunc) const; template<typename T> - std::vector<ScMatrix::IterateResult> ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp); + std::vector<ScMatrix::IterateResult> ApplyCollectOperation(const std::vector<T>& aOp); void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2, SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool); @@ -1181,16 +1181,16 @@ public: template<typename Op> class WalkElementBlocksMultipleValues { - const std::vector<std::unique_ptr<Op>>* mpOp; + const std::vector<Op>* mpOp; std::vector<ScMatrix::IterateResult> maRes; bool mbFirst:1; public: - WalkElementBlocksMultipleValues(const std::vector<std::unique_ptr<Op>>& aOp) : + WalkElementBlocksMultipleValues(const std::vector<Op>& aOp) : mpOp(&aOp), mbFirst(true) { for (const auto& rpOp : *mpOp) { - maRes.emplace_back(rpOp->mInitVal, rpOp->mInitVal, 0); + maRes.emplace_back(rpOp.mInitVal, rpOp.mInitVal, 0); } maRes.emplace_back(0.0, 0.0, 0); // count } @@ -1227,7 +1227,7 @@ public: { for (size_t i = 0u; i < mpOp->size(); ++i) { - (*(*mpOp)[i])(maRes[i].mfFirst, *it); + (*mpOp)[i](maRes[i].mfFirst, *it); } mbFirst = false; } @@ -1235,7 +1235,7 @@ public: { for (size_t i = 0u; i < mpOp->size(); ++i) { - (*(*mpOp)[i])(maRes[i].mfRest, *it); + (*mpOp)[i](maRes[i].mfRest, *it); } } } @@ -1254,7 +1254,7 @@ public: { for (size_t i = 0u; i < mpOp->size(); ++i) { - (*(*mpOp)[i])(maRes[i].mfFirst, *it); + (*mpOp)[i](maRes[i].mfFirst, *it); } mbFirst = false; } @@ -1262,7 +1262,7 @@ public: { for (size_t i = 0u; i < mpOp->size(); ++i) { - (*(*mpOp)[i])(maRes[i].mfRest, *it); + (*mpOp)[i](maRes[i].mfRest, *it); } } } @@ -2433,7 +2433,7 @@ void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat) } template<typename T> -std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp) +std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<T>& aOp) { WalkElementBlocksMultipleValues<T> aFunc(aOp); aFunc = maMat.walk(std::move(aFunc)); @@ -3460,7 +3460,7 @@ void ScMatrix::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, pImpl->ExecuteOperation(rStartPos, rEndPos, aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc); } -std::vector<ScMatrix::IterateResult> ScMatrix::Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp) +std::vector<ScMatrix::IterateResult> ScMatrix::Collect(const std::vector<sc::op::Op>& aOp) { return pImpl->ApplyCollectOperation(aOp); } |