[Libreoffice-commits] core.git: 2 commits - sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 24 12:53:17 UTC 2018
sc/source/core/tool/interpr1.cxx | 63 +++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 32 deletions(-)
New commits:
commit ce91b05fd79e34bbbb07cbec75f2fedf8b1960f3
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Aug 24 11:57:52 2018 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Fri Aug 24 14:52:59 2018 +0200
Avoid unnecessary copy of vector if nothing omitted, tdf#117016 follow-up
Change-Id: Ifed272642c0594377d66d6cb0c36a1b775e6bb20
Reviewed-on: https://gerrit.libreoffice.org/59550
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 0e49f38507e5..b5bebbb0f2f8 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6787,9 +6787,20 @@ void ScInterpreter::ScLookup()
PushNA();
return;
}
- ScMatrixRef pTempMat = GetNewMat( 1, vArray.size());
- pTempMat->PutDoubleVector( vArray, 0, 0);
- pDataMat2 = pTempMat;
+ 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;
+ }
}
else
{
@@ -6807,16 +6818,22 @@ void ScInterpreter::ScLookup()
PushNA();
return;
}
- ScMatrixRef pTempMat = GetNewMat( vArray.size(), 1);
- const size_t n = vArray.size();
- for (size_t i=0; i < n; ++i)
- pTempMat->PutDouble( vArray[i], i, 0);
- pDataMat2 = pTempMat;
+ const size_t nElems = vArray.size();
+ if (nElems == nC)
+ {
+ // No error value omitted, use as is.
+ pDataMat2 = pDataMat;
+ std::vector<long>().swap( vIndex);
+ }
+ else
+ {
+ ScMatrixRef pTempMat = GetNewMat( nElems, 1);
+ for (size_t i=0; i < nElems; ++i)
+ pTempMat->PutDouble( vArray[i], i, 0);
+ pDataMat2 = pTempMat;
+ nLenMajor = nElems;
+ }
}
- if (vArray.size() == nLenMajor)
- std::vector<long>().swap( vIndex); // no error value omitted
- else
- nLenMajor = vArray.size();
}
else
{
commit 1d0d5734ffaf6f56699c5315b6427ac832af6a13
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Aug 24 11:13:00 2018 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Fri Aug 24 14:52:47 2018 +0200
Eliminate unnecessary per element copy of matrix' first col/row
Change-Id: I12e282bc9e999db674e02218160b6ac199aedc48
Reviewed-on: https://gerrit.libreoffice.org/59548
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 bfc26230ec35..0e49f38507e5 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6820,26 +6820,8 @@ void ScInterpreter::ScLookup()
}
else
{
- if (bVertical)
- {
- ScMatrixRef pTempMat = GetNewMat(1, nR);
- for (SCSIZE i = 0; i < nR; ++i)
- if (pDataMat->IsValue(0, i))
- pTempMat->PutDouble(pDataMat->GetDouble(0, i), 0, i);
- else
- pTempMat->PutString(pDataMat->GetString(0, i), 0, i);
- pDataMat2 = pTempMat;
- }
- else
- {
- ScMatrixRef pTempMat = GetNewMat(nC, 1);
- for (SCSIZE i = 0; i < nC; ++i)
- if (pDataMat->IsValue(i, 0))
- pTempMat->PutDouble(pDataMat->GetDouble(i, 0), i, 0);
- else
- pTempMat->PutString(pDataMat->GetString(i, 0), i, 0);
- pDataMat2 = pTempMat;
- }
+ // Just use as is with the VectorMatrixAccessor.
+ pDataMat2 = pDataMat;
}
// Do not propagate errors from matrix while searching.
More information about the Libreoffice-commits
mailing list