diff options
author | Eike Rathke <erack@redhat.com> | 2017-06-01 17:58:58 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-06-01 18:00:39 +0200 |
commit | e4f2aab11721cc6842c2c821ff9dacebc6095a56 (patch) | |
tree | 2a98180ea92b1590191cdc1b72e7f9721717728a | |
parent | 5cd1da66013015c091b7f0a86a04f7c465fd6b8d (diff) |
Perf: do not calculate a null-operation with the result matrix, tdf#58874
i.e. with an empty set within an svRefList when advancing to the next reference.
Change-Id: Iae81c3a0cd3c30ab113ad74881a0f28b78b0973d
-rw-r--r-- | sc/source/core/tool/interpr6.cxx | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 0db0bd226373..cff34f262ad8 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -506,7 +506,11 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) short nParamCount = GetByte(); const SCSIZE nMatRows = GetRefListArrayMaxSize( nParamCount); ScMatrixRef xResMat, xResCount; - double fRes = ( eFunc == ifPRODUCT ) ? 1.0 : 0.0; + auto ResInitVal = [eFunc]() + { + return (eFunc == ifPRODUCT) ? 1.0 : 0.0; + }; + double fRes = ResInitVal(); double fVal = 0.0; double fMem = 0.0; // first numeric value != 0.0 sal_uLong nCount = 0; @@ -753,19 +757,27 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { // Current value and values from vector are operands // for each vector position. - for (SCSIZE i=0; i < nMatRows; ++i) + if (nCount && xResCount) { - if (xResCount) + for (SCSIZE i=0; i < nMatRows; ++i) + { xResCount->PutDouble( xResCount->GetDouble(0,i) + nCount, 0,i); - double fVecRes = xResMat->GetDouble(0,i); - if (eFunc == ifPRODUCT) - fVecRes *= fRes; - else - fVecRes += fRes; - xResMat->PutDouble( fVecRes, 0,i); + } + } + if (fRes != ResInitVal()) + { + for (SCSIZE i=0; i < nMatRows; ++i) + { + double fVecRes = xResMat->GetDouble(0,i); + if (eFunc == ifPRODUCT) + fVecRes *= fRes; + else + fVecRes += fRes; + xResMat->PutDouble( fVecRes, 0,i); + } } } - fRes = ((eFunc == ifPRODUCT) ? 1.0 : 0.0); + fRes = ResInitVal(); nCount = 0; } } @@ -943,7 +955,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) fVecRes += fRes; xResMat->PutDouble( fVecRes, 0,nRefArrayPos); // Reset. - fRes = ((eFunc == ifPRODUCT) ? 1.0 : 0.0); + fRes = ResInitVal(); nCount = 0; nRefArrayPos = std::numeric_limits<size_t>::max(); } |