summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-06-01 19:46:27 +0200
committerEike Rathke <erack@redhat.com>2017-06-01 19:46:34 +0200
commit41ba5f649f361bfa6965a7c8f2e2ffa084317c45 (patch)
treee228bab1a5bfb76aa6f939039152cbc69036b2c7
parent9c32973e0ea91fbc1d9eb7daa55967c4a18f3f72 (diff)
Perf: do not calculate a null-operation with the result matrix, tdf#58874
Change-Id: I6fe115ff7ec7960900863ddaf1cd1dc48975fd74
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/tool/interpr1.cxx18
2 files changed, 15 insertions, 5 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 53190038bd9b..9b36afec2e05 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -575,7 +575,7 @@ size_t GetRefListArrayMaxSize( short nParamCount );
/** Switch to array reference list if current TOS is one and create/init or
update matrix and return true. Else return false. */
bool SwitchToArrayRefList( ScMatrixRef& xResMat, SCSIZE nMatRows, double fCurrent,
- const std::function<void( SCSIZE i, double fCurrent )>& MatOpFunc );
+ const std::function<void( SCSIZE i, double fCurrent )>& MatOpFunc, bool bDoMatOp );
void IterateParameters( ScIterFunc, bool bTextAsZero = false );
void ScSumSQ();
void ScSum();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 845be4b5e523..0d75c3f79834 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3457,7 +3457,7 @@ void ScInterpreter::ScUnichar()
}
bool ScInterpreter::SwitchToArrayRefList( ScMatrixRef& xResMat, SCSIZE nMatRows, double fCurrent,
- const std::function<void( SCSIZE i, double fCurrent )>& MatOpFunc )
+ const std::function<void( SCSIZE i, double fCurrent )>& MatOpFunc, bool bDoMatOp )
{
const ScRefListToken* p = dynamic_cast<const ScRefListToken*>(pStack[sp-1]);
if (!p || !p->IsArrayResult())
@@ -3470,7 +3470,7 @@ bool ScInterpreter::SwitchToArrayRefList( ScMatrixRef& xResMat, SCSIZE nMatRows,
xResMat = GetNewMat( 1, nMatRows, true);
xResMat->FillDouble( fCurrent, 0,0, 0,nMatRows-1);
}
- else
+ else if (bDoMatOp)
{
// Current value and values from vector are operands
// for each vector position.
@@ -3533,8 +3533,13 @@ void ScInterpreter::ScMin( bool bTextAsZero )
break;
case svRefList :
{
- if (SwitchToArrayRefList( xResMat, nMatRows, nMin, MatOpFunc))
+ // bDoMatOp only for non-array value when switching to
+ // ArrayRefList.
+ if (SwitchToArrayRefList( xResMat, nMatRows, nMin, MatOpFunc,
+ nRefArrayPos == std::numeric_limits<size_t>::max()))
+ {
nRefArrayPos = nRefInList;
+ }
}
SAL_FALLTHROUGH;
case svDoubleRef :
@@ -3683,8 +3688,13 @@ void ScInterpreter::ScMax( bool bTextAsZero )
break;
case svRefList :
{
- if (SwitchToArrayRefList( xResMat, nMatRows, nMax, MatOpFunc))
+ // bDoMatOp only for non-array value when switching to
+ // ArrayRefList.
+ if (SwitchToArrayRefList( xResMat, nMatRows, nMax, MatOpFunc,
+ nRefArrayPos == std::numeric_limits<size_t>::max()))
+ {
nRefArrayPos = nRefInList;
+ }
}
SAL_FALLTHROUGH;
case svDoubleRef :