diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-19 13:08:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-19 13:57:40 -0400 |
commit | 8e8b43a03e77dd251876c1de0ac06eeeb09192cd (patch) | |
tree | fa10f139f9ea27368c54182f234d62d7b1870731 /sc | |
parent | 72d4b574f11979d5487309737172869e9c3181a9 (diff) |
Generate boolean comparison result array in one step.
This is faster than doing it in two steps as was previously done.
Change-Id: I1417e9c6add9d20ee8d68f0c1c91c7d24a0f79b3
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/compare.hxx | 2 | ||||
-rw-r--r-- | sc/inc/scmatrix.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 36 |
4 files changed, 35 insertions, 32 deletions
diff --git a/sc/inc/compare.hxx b/sc/inc/compare.hxx index b4e4a50b2a96..0bbf8dcc45fd 100644 --- a/sc/inc/compare.hxx +++ b/sc/inc/compare.hxx @@ -35,9 +35,11 @@ struct Compare bool bVal[2]; bool bEmpty[2]; + ScQueryOp meOp; bool mbIgnoreCase; Compare( OUString* p1, OUString* p2 ) : + meOp(SC_EQUAL), mbIgnoreCase(true) { pVal[0] = p1; diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 6fe7a5e2f615..b2a5d8d58aa7 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -109,6 +109,8 @@ struct ScMatrixValue */ class SC_DLLPUBLIC ScMatrix { + friend class ScMatrixImpl; + ScMatrixImpl* pImpl; mutable size_t nRefCnt; // reference count diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index d308936d21be..69cfa10118a7 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -883,6 +883,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO { OUString aVal1, aVal2; sc::Compare aComp( &aVal1, &aVal2 ); + aComp.meOp = eOp; aComp.mbIgnoreCase = pDok->GetDocOptions().IsIgnoreCase(); sc::RangeMatrix aMat[2]; ScAddress aAdr; @@ -1033,32 +1034,6 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO ScMatrix& rMat = *aMat[i].mpMat; ScMatrix& rResMat = *aRes.mpMat; rMat.CompareMatrix(rResMat, aComp, i, pOptions); - - switch (eOp) - { - case SC_EQUAL: - aRes.mpMat->CompareEqual(); - break; - case SC_LESS: - aRes.mpMat->CompareLess(); - break; - case SC_GREATER: - aRes.mpMat->CompareGreater(); - break; - case SC_LESS_EQUAL: - aRes.mpMat->CompareLessEqual(); - break; - case SC_GREATER_EQUAL: - aRes.mpMat->CompareGreaterEqual(); - break; - case SC_NOT_EQUAL: - aRes.mpMat->CompareNotEqual(); - break; - default: - OSL_TRACE( "ScInterpreter::QueryMat: unhandled comparison operator: %d", (int)eOp); - aRes.mpMat.reset(); - return aRes; - } } nCurFmtType = nFuncFmtType = NUMBERFORMAT_LOGICAL; diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index cc2106d9c432..489dcfefb255 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -1217,12 +1217,36 @@ class CompareMatrixFunc : std::unary_function<MatrixImplType::element_block_type sc::Compare& mrComp; size_t mnMatPos; sc::CompareOptions* mpOptions; - - std::vector<double> maResValues; + std::vector<bool> maResValues; void compare() { - maResValues.push_back(sc::CompareFunc(mrComp, mpOptions)); + double fVal = sc::CompareFunc(mrComp, mpOptions); + bool bRes = false; + switch (mrComp.meOp) + { + case SC_EQUAL: + bRes = fVal == 0.0; + break; + case SC_LESS: + bRes = fVal < 0.0; + break; + case SC_GREATER: + bRes = fVal > 0.0; + break; + case SC_LESS_EQUAL: + bRes = fVal <= 0.0; + break; + case SC_GREATER_EQUAL: + bRes = fVal >= 0.0; + break; + case SC_NOT_EQUAL: + bRes = fVal != 0.0; + break; + default: + OSL_TRACE( "CompareMatrixFunc: unhandled comparison operator: %d", (int)mrComp.meOp); + } + maResValues.push_back(bRes); } public: @@ -1295,7 +1319,7 @@ public: } } - const std::vector<double>& getValues() const + const std::vector<bool>& getValues() const { return maResValues; } @@ -1501,9 +1525,9 @@ void ScMatrixImpl::CompareMatrix( maMat.walk(aFunc); // We assume the result matrix has the same dimension as this matrix. - const std::vector<double>& rResVal = aFunc.getValues(); + const std::vector<bool>& rResVal = aFunc.getValues(); if (nSize == rResVal.size()) - rResMat.PutDouble(&rResVal[0], rResVal.size(), 0, 0); + rResMat.pImpl->maMat.set(0, 0, rResVal.begin(), rResVal.end()); } void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero ) const |