Kaydet (Commit) d3b77628 authored tarafından Eike Rathke's avatar Eike Rathke

Resolves: tdf#108292 WalkAndMatchElements: really limit the match

... to the columns queried, not just when entering an mdds node. Otherwise it
would return an unexpected index, plus bailing out early spares unnecessary
comparisons for the rest of a node block.

Regression of

    commit 3fed1662
    Date:   Fri Aug 16 16:29:38 2013 +0200

that started to use

    commit 7334f8db
    Date:   Fri Aug 16 16:29:27 2013 +0200

with its bad implementation.

Just that VLOOKUP on a matrix with a larger block of same typed data as the
query *and* a match in an excess column seems to be rare..

Change-Id: Ia4ef3fd56490de82910d5aa13a84be2de851f9b0
üst aa588903
......@@ -1284,6 +1284,8 @@ public:
size_t getMatching() const { return mnResult; }
size_t getRemainingCount() const { return ((mnCol2 + 1) * maSize.row) - mnIndex; }
size_t compare(const MatrixImplType::element_block_node_type& node) const;
void operator() (const MatrixImplType::element_block_node_type& node)
......@@ -1293,7 +1295,7 @@ public:
return;
// limit lookup to the requested columns
if ((mnCol1 * maSize.row) <= mnIndex && mnIndex < ((mnCol2 + 1) * maSize.row))
if ((mnCol1 * maSize.row) <= mnIndex && getRemainingCount() > 0)
{
mnResult = compare(node);
}
......@@ -1314,7 +1316,8 @@ size_t WalkAndMatchElements<double>::compare(const MatrixImplType::element_block
block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data);
for (; it != itEnd; ++it, nCount++)
const size_t nRemaining = getRemainingCount();
for (; it != itEnd && nCount < nRemaining; ++it, ++nCount)
{
if (*it == maMatchValue)
{
......@@ -1329,7 +1332,8 @@ size_t WalkAndMatchElements<double>::compare(const MatrixImplType::element_block
block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data);
for (; it != itEnd; ++it, ++nCount)
const size_t nRemaining = getRemainingCount();
for (; it != itEnd && nCount < nRemaining; ++it, ++nCount)
{
if (int(*it) == maMatchValue)
{
......@@ -1359,7 +1363,8 @@ size_t WalkAndMatchElements<svl::SharedString>::compare(const MatrixImplType::el
block_type::const_iterator it = block_type::begin(*node.data);
block_type::const_iterator itEnd = block_type::end(*node.data);
for (; it != itEnd; ++it, ++nCount)
const size_t nRemaining = getRemainingCount();
for (; it != itEnd && nCount < nRemaining; ++it, ++nCount)
{
if (it->getDataIgnoreCase() == maMatchValue.getDataIgnoreCase())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment