summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/scmatrix.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/tool/scmatrix.cxx')
-rw-r--r--sc/source/core/tool/scmatrix.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 1807a11c53cc..30fb6eb0b36f 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1264,24 +1264,25 @@ template<typename Type>
class WalkAndMatchElements : public std::unary_function<MatrixImplType::element_block_node_type, void>
{
Type maMatchValue;
- MatrixImplType::size_pair_type maSize;
- size_t mnCol1;
- size_t mnCol2;
+ const size_t mnStartIndex;
+ const size_t mnStopIndex;
size_t mnResult;
size_t mnIndex;
public:
WalkAndMatchElements(Type aMatchValue, const MatrixImplType::size_pair_type& aSize, size_t nCol1, size_t nCol2) :
maMatchValue(aMatchValue),
- maSize(aSize),
- mnCol1(nCol1),
- mnCol2(nCol2),
+ mnStartIndex( nCol1 * aSize.row ),
+ mnStopIndex( (nCol2 + 1) * aSize.row ),
mnResult(ResultNotSet),
mnIndex(0) {}
size_t getMatching() const { return mnResult; }
- size_t getRemainingCount() const { return ((mnCol2 + 1) * maSize.row) - mnIndex; }
+ size_t getRemainingCount() const
+ {
+ return mnIndex < mnStopIndex ? mnStopIndex - mnIndex : 0;
+ }
size_t compare(const MatrixImplType::element_block_node_type& node) const;
@@ -1292,7 +1293,7 @@ public:
return;
// limit lookup to the requested columns
- if ((mnCol1 * maSize.row) <= mnIndex && getRemainingCount() > 0)
+ if (mnStartIndex <= mnIndex && getRemainingCount() > 0)
{
mnResult = compare(node);
}