[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 24 12:53:53 UTC 2018
sc/source/core/tool/interpr1.cxx | 71 +++++++++++++--------------------------
1 file changed, 24 insertions(+), 47 deletions(-)
New commits:
commit 3aa566566923e3a2d582d72c1141774056bb9554
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Aug 24 12:33:52 2018 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Fri Aug 24 14:53:20 2018 +0200
Consolidate duplicated code, use VectorMatrixAccessor, tdf#117016 follow-up
Change-Id: I52650913034b1d490ad567867ad4405531095d92
Reviewed-on: https://gerrit.libreoffice.org/59551
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b5bebbb0f2f8..1738538c86db 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6771,59 +6771,37 @@ void ScInterpreter::ScLookup()
if (bOmitErrorValues)
{
std::vector<double> vArray;
- if (bVertical)
+ VectorMatrixAccessor aMatAcc(*pDataMat, bVertical);
+ const SCSIZE nElements = aMatAcc.GetElementCount();
+ for (SCSIZE i=0; i < nElements; ++i)
{
- for (SCSIZE i = 0; i < nR; ++i)
+ const double fVal = aMatAcc.GetDouble(i);
+ if (rtl::math::isFinite(fVal))
{
- const double fVal = pDataMat->GetDouble(0, i);
- if (rtl::math::isFinite(fVal))
- {
- vArray.push_back(fVal);
- vIndex.push_back(i);
- }
- }
- if (vArray.empty())
- {
- PushNA();
- return;
- }
- const size_t nElems = vArray.size();
- if (nElems == nR)
- {
- // No error value omitted, use as is.
- pDataMat2 = pDataMat;
- std::vector<long>().swap( vIndex);
- }
- else
- {
- ScMatrixRef pTempMat = GetNewMat( 1, nElems);
- pTempMat->PutDoubleVector( vArray, 0, 0);
- pDataMat2 = pTempMat;
- nLenMajor = nElems;
+ vArray.push_back(fVal);
+ vIndex.push_back(i);
}
}
+ if (vArray.empty())
+ {
+ PushNA();
+ return;
+ }
+ const size_t nElems = vArray.size();
+ if (nElems == nElements)
+ {
+ // No error value omitted, use as is.
+ pDataMat2 = pDataMat;
+ std::vector<long>().swap( vIndex);
+ }
else
{
- for (SCSIZE i = 0; i < nC; ++i)
- {
- const double fVal = pDataMat->GetDouble(i, 0);
- if (rtl::math::isFinite(fVal))
- {
- vArray.push_back(fVal);
- vIndex.push_back(i);
- }
- }
- if (vArray.empty())
- {
- PushNA();
- return;
- }
- const size_t nElems = vArray.size();
- if (nElems == nC)
+ nLenMajor = nElems;
+ if (bVertical)
{
- // No error value omitted, use as is.
- pDataMat2 = pDataMat;
- std::vector<long>().swap( vIndex);
+ ScMatrixRef pTempMat = GetNewMat( 1, nElems);
+ pTempMat->PutDoubleVector( vArray, 0, 0);
+ pDataMat2 = pTempMat;
}
else
{
@@ -6831,7 +6809,6 @@ void ScInterpreter::ScLookup()
for (size_t i=0; i < nElems; ++i)
pTempMat->PutDouble( vArray[i], i, 0);
pDataMat2 = pTempMat;
- nLenMajor = nElems;
}
}
}
More information about the Libreoffice-commits
mailing list