diff options
author | Eike Rathke <erack@redhat.com> | 2018-08-24 11:57:52 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-08-24 14:52:59 +0200 |
commit | ce91b05fd79e34bbbb07cbec75f2fedf8b1960f3 (patch) | |
tree | 081daf829445f6c8c9f649f5c6c21f6373db8d3c /sc | |
parent | 1d0d5734ffaf6f56699c5315b6427ac832af6a13 (diff) |
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@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 41 |
1 files changed, 29 insertions, 12 deletions
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 { |