diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-09-23 21:36:36 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-24 11:17:05 +0200 |
commit | 0314b3e22b155b83036b83b9d365f596ea8064e8 (patch) | |
tree | f3a75b1310d550b7a2106cd7c3ff45b559d9f45c /sc/source/core/tool/scmatrix.cxx | |
parent | 1be1327b6059403638b180a92577dffe8af3c6ea (diff) |
coverity#1438870 Big parameter passed by value
Change-Id: I6ade72ed19b63b7f68c8f58c57bb409eab55e55c
Reviewed-on: https://gerrit.libreoffice.org/60919
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/core/tool/scmatrix.cxx')
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 90 |
1 files changed, 50 insertions, 40 deletions
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 3c983cd2ecc8..d9b500d1146d 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -2506,11 +2506,9 @@ std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const s namespace { -class WalkElementBlockOperation +struct ElementBlock { -public: - - WalkElementBlockOperation(size_t nRowSize, + ElementBlock(size_t nRowSize, ScFullMatrix::DoubleOpFunction const & aDoubleFunc, ScFullMatrix::BoolOpFunction const & aBoolFunc, ScFullMatrix::StringOpFunction const & aStringFunc, @@ -2525,6 +2523,25 @@ public: { } + size_t mnRowSize; + size_t mnRowPos; + size_t mnColPos; + + ScFullMatrix::DoubleOpFunction maDoubleFunc; + ScFullMatrix::BoolOpFunction maBoolFunc; + ScFullMatrix::StringOpFunction maStringFunc; + ScFullMatrix::EmptyOpFunction maEmptyFunc; +}; + +class WalkElementBlockOperation +{ +public: + + WalkElementBlockOperation(ElementBlock& rElementBlock) + : mrElementBlock(rElementBlock) + { + } + void operator()(const MatrixImplType::element_block_node_type& node) { switch (node.type) @@ -2539,12 +2556,12 @@ public: std::advance(itEnd, node.size); for (auto itr = it; itr != itEnd; ++itr) { - maDoubleFunc(mnRowPos, mnColPos, *itr); - ++mnRowPos; - if (mnRowPos >= mnRowSize) + mrElementBlock.maDoubleFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr); + ++mrElementBlock.mnRowPos; + if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize) { - mnRowPos = 0; - ++mnColPos; + mrElementBlock.mnRowPos = 0; + ++mrElementBlock.mnColPos; } } } @@ -2559,12 +2576,12 @@ public: std::advance(itEnd, node.size); for (auto itr = it; itr != itEnd; ++itr) { - maStringFunc(mnRowPos, mnColPos, *itr); - ++mnRowPos; - if (mnRowPos >= mnRowSize) + mrElementBlock.maStringFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr); + ++mrElementBlock.mnRowPos; + if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize) { - mnRowPos = 0; - ++mnColPos; + mrElementBlock.mnRowPos = 0; + ++mrElementBlock.mnColPos; } } } @@ -2579,12 +2596,12 @@ public: std::advance(itEnd, node.size); for (auto itr = it; itr != itEnd; ++itr) { - maBoolFunc(mnRowPos, mnColPos, *itr); - ++mnRowPos; - if (mnRowPos >= mnRowSize) + mrElementBlock.maBoolFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr); + ++mrElementBlock.mnRowPos; + if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize) { - mnRowPos = 0; - ++mnColPos; + mrElementBlock.mnRowPos = 0; + ++mrElementBlock.mnColPos; } } } @@ -2593,12 +2610,12 @@ public: { for (size_t i=0; i < node.size; ++i) { - maEmptyFunc(mnRowPos, mnColPos); - ++mnRowPos; - if (mnRowPos >= mnRowSize) + mrElementBlock.maEmptyFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos); + ++mrElementBlock.mnRowPos; + if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize) { - mnRowPos = 0; - ++mnColPos; + mrElementBlock.mnRowPos = 0; + ++mrElementBlock.mnColPos; } } } @@ -2607,12 +2624,12 @@ public: { SAL_WARN("sc.core","WalkElementBlockOperation - unhandled element_integer"); // No function (yet?), but advance row and column count. - mnColPos += node.size / mnRowSize; - mnRowPos += node.size % mnRowSize; - if (mnRowPos >= mnRowSize) + mrElementBlock.mnColPos += node.size / mrElementBlock.mnRowSize; + mrElementBlock.mnRowPos += node.size % mrElementBlock.mnRowSize; + if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize) { - mnRowPos = 0; - ++mnColPos; + mrElementBlock.mnRowPos = 0; + ++mrElementBlock.mnColPos; } } break; @@ -2621,14 +2638,7 @@ public: private: - size_t mnRowSize; - size_t mnRowPos; - size_t mnColPos; - - ScFullMatrix::DoubleOpFunction maDoubleFunc; - ScFullMatrix::BoolOpFunction maBoolFunc; - ScFullMatrix::StringOpFunction maStringFunc; - ScFullMatrix::EmptyOpFunction maEmptyFunc; + ElementBlock& mrElementBlock; }; } @@ -2638,10 +2648,10 @@ void ScMatrixImpl::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const ScMatrix::BoolOpFunction& aBoolFunc, const ScMatrix::StringOpFunction& aStringFunc, const ScMatrix::EmptyOpFunction& aEmptyFunc) const { - WalkElementBlockOperation aFunc(maMat.size().row, - aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc); + ElementBlock aPayload(maMat.size().row, aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc); + WalkElementBlockOperation aFunc(aPayload); maMat.walk( - std::move(aFunc), + aFunc, MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second), MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second)); } |