[Libreoffice-commits] core.git: sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 13 12:04:58 UTC 2021
sc/source/core/tool/interpr1.cxx | 37 ++++++++++++++--------------
sc/source/core/tool/interpr2.cxx | 2 -
sc/source/core/tool/interpr4.cxx | 2 -
sc/source/core/tool/interpr5.cxx | 50 +++++++++++++++++++--------------------
sc/source/core/tool/interpr8.cxx | 6 ++--
5 files changed, 48 insertions(+), 49 deletions(-)
New commits:
commit f6d1da91ccda960d1ee738d688a2cb374e576aef
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Tue Apr 13 12:14:08 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Apr 13 14:04:10 2021 +0200
tdf#130326 no need to fill ScMatrix with zeros here
when we are about to overwrite the data anyway.
Takes my load time from 24s ro 23s.
The important change (for this test file) is in
ScInterpreter::ScAmpersand
but I changed all the other places that have the
same problem.
Change-Id: I95b8ac3b2c10a8b638551e13f6f582e793058833
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114041
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 6c3b01c6a049..f210b29049be 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1056,7 +1056,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO
aMat[1].mpMat->GetDimensions(nC1, nR1);
SCSIZE nC = std::max( nC0, nC1 );
SCSIZE nR = std::max( nR0, nR1 );
- aRes.mpMat = GetNewMat( nC, nR);
+ aRes.mpMat = GetNewMat( nC, nR, /*bEmpty*/true );
if (!aRes.mpMat)
return aRes;
for ( SCSIZE j=0; j<nC; j++ )
@@ -1577,7 +1577,7 @@ void ScInterpreter::ScNeg()
{
SCSIZE nC, nR;
pMat->GetDimensions( nC, nR );
- ScMatrixRef pResMat = GetNewMat( nC, nR);
+ ScMatrixRef pResMat = GetNewMat( nC, nR, /*bEmpty*/true );
if ( !pResMat )
PushIllegalArgument();
else
@@ -1621,7 +1621,7 @@ void ScInterpreter::ScNot()
{
SCSIZE nC, nR;
pMat->GetDimensions( nC, nR );
- ScMatrixRef pResMat = GetNewMat( nC, nR);
+ ScMatrixRef pResMat = GetNewMat( nC, nR, /*bEmpty*/true);
if ( !pResMat )
PushIllegalArgument();
else
@@ -1762,7 +1762,7 @@ void ScInterpreter::ScRandomImpl( const std::function<double( double fFirst, dou
nCols = 1;
if (nRows == 0)
nRows = 1;
- ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), static_cast<SCSIZE>(nRows));
+ ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), static_cast<SCSIZE>(nRows), /*bEmpty*/true );
if (!pResMat)
PushError( FormulaError::MatrixSize);
else
@@ -4394,7 +4394,7 @@ void ScInterpreter::ScColumn()
// matrix result is not available yet.
nCols = 1;
}
- ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), 1);
+ ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCols), 1, /*bEmpty*/true );
if (pResMat)
{
for (SCCOL i=0; i < nCols; ++i)
@@ -4454,7 +4454,7 @@ void ScInterpreter::ScColumn()
if (nCol2 > nCol1)
{
ScMatrixRef pResMat = GetNewMat(
- static_cast<SCSIZE>(nCol2-nCol1+1), 1);
+ static_cast<SCSIZE>(nCol2-nCol1+1), 1, /*bEmpty*/true);
if (pResMat)
{
for (SCCOL i = nCol1; i <= nCol2; i++)
@@ -4498,7 +4498,7 @@ void ScInterpreter::ScRow()
// matrix result is not available yet.
nRows = 1;
}
- ScMatrixRef pResMat = GetNewMat( 1, static_cast<SCSIZE>(nRows));
+ ScMatrixRef pResMat = GetNewMat( 1, static_cast<SCSIZE>(nRows), /*bEmpty*/true);
if (pResMat)
{
for (SCROW i=0; i < nRows; i++)
@@ -4557,7 +4557,7 @@ void ScInterpreter::ScRow()
if (nRow2 > nRow1)
{
ScMatrixRef pResMat = GetNewMat( 1,
- static_cast<SCSIZE>(nRow2-nRow1+1));
+ static_cast<SCSIZE>(nRow2-nRow1+1), /*bEmpty*/true);
if (pResMat)
{
for (SCROW i = nRow1; i <= nRow2; i++)
@@ -5115,7 +5115,7 @@ void ScInterpreter::ScCountEmptyCells()
const SCSIZE nMatRows = GetRefListArrayMaxSize(1);
// There's either one RefList and nothing else, or none.
- ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows) : nullptr);
+ ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows, /*bEmpty*/true ) : nullptr);
sal_uLong nMaxCount = 0, nCount = 0;
switch (GetStackType())
{
@@ -5335,7 +5335,7 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc )
short nParam = 1;
const SCSIZE nMatRows = GetRefListArrayMaxSize( nParam);
// There's either one RefList and nothing else, or none.
- ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows) : nullptr);
+ ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows, /*bEmpty*/true ) : nullptr);
SCSIZE nRefListArrayPos = 0;
size_t nRefInList = 0;
while (nParam-- > 0)
@@ -5694,7 +5694,7 @@ void ScInterpreter::ScCountIf()
short nParam = 1;
const SCSIZE nMatRows = GetRefListArrayMaxSize( nParam);
// There's either one RefList and nothing else, or none.
- ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows) : nullptr);
+ ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows, /*bEmpty*/true ) : nullptr);
SCSIZE nRefListArrayPos = 0;
size_t nRefInList = 0;
while (nParam-- > 0)
@@ -6357,7 +6357,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
const bool bAppliedArray = (!bRefArrayMain && nRefArrayMainPos == 0);
if (nRefArrayMainPos == 0)
- xResMat = GetNewMat( 1, nRefArrayRows);
+ xResMat = GetNewMat( 1, nRefArrayRows, /*bEmpty*/true );
if (pMainMatrix)
{
@@ -6468,7 +6468,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
}
else
{
- xResMat = GetNewMat( 1, nRefArrayRows);
+ xResMat = GetNewMat( 1, nRefArrayRows, /*bEmpty*/true );
for (size_t i=0, n = vRefArrayConditions.size(); i < n; ++i)
{
double fCount = 0.0;
@@ -6477,8 +6477,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
if (rCond == nQueryCount)
++fCount;
}
- if (fCount)
- xResMat->PutDouble( fCount, 0, i);
+ xResMat->PutDouble( fCount, 0, i);
}
}
}
@@ -6886,13 +6885,13 @@ void ScInterpreter::ScLookup()
nLenMajor = nElems;
if (bVertical)
{
- ScMatrixRef pTempMat = GetNewMat( 1, nElems);
+ ScMatrixRef pTempMat = GetNewMat( 1, nElems, /*bEmpty*/true );
pTempMat->PutDoubleVector( vArray, 0, 0);
pDataMat2 = pTempMat;
}
else
{
- ScMatrixRef pTempMat = GetNewMat( nElems, 1);
+ ScMatrixRef pTempMat = GetNewMat( nElems, 1, /*bEmpty*/true );
for (size_t i=0; i < nElems; ++i)
pTempMat->PutDouble( vArray[i], i, 0);
pDataMat2 = pTempMat;
@@ -8642,7 +8641,7 @@ void ScInterpreter::ScIndex()
}
else if (nCol == 0)
{
- ScMatrixRef pResMat = GetNewMat(nC, 1);
+ ScMatrixRef pResMat = GetNewMat(nC, 1, /*bEmpty*/true);
if (pResMat)
{
SCSIZE nRowMinus1 = static_cast<SCSIZE>(nRow - 1);
@@ -8660,7 +8659,7 @@ void ScInterpreter::ScIndex()
}
else if (nRow == 0)
{
- ScMatrixRef pResMat = GetNewMat(1, nR);
+ ScMatrixRef pResMat = GetNewMat(1, nR, /*bEmpty*/true);
if (pResMat)
{
SCSIZE nColMinus1 = static_cast<SCSIZE>(nCol - 1);
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 6bfd1884dbd0..a14c84b69f92 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2817,7 +2817,7 @@ void ScInterpreter::ScDde()
{
SCSIZE nC, nR;
pLinkMat->GetDimensions(nC, nR);
- ScMatrixRef pNewMat = GetNewMat( nC, nR);
+ ScMatrixRef pNewMat = GetNewMat( nC, nR, /*bEmpty*/true);
if (pNewMat)
{
pLinkMat->MatCopy(*pNewMat); // copy
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 593165275288..da1edb25c922 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3467,7 +3467,7 @@ void ScInterpreter::ScMacro()
nColIdx = 1;
nRowIdx = 0;
}
- ScMatrixRef pMat = GetNewMat( nC, nR);
+ ScMatrixRef pMat = GetNewMat( nC, nR, /*bEmpty*/true);
if ( pMat )
{
SbxVariable* pV;
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 14615174e622..8fd5e55d32bd 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -739,7 +739,7 @@ void ScInterpreter::ScEMat()
PushError( FormulaError::MatrixSize);
else
{
- ScMatrixRef pRMat = GetNewMat(nDim, nDim);
+ ScMatrixRef pRMat = GetNewMat(nDim, nDim, /*bEmpty*/true);
if (pRMat)
{
MEMat(pRMat, nDim);
@@ -1005,7 +1005,7 @@ void ScInterpreter::ScMatInv()
// LUP decomposition is done inplace, use copy.
ScMatrixRef xLU = pMat->Clone();
// The result matrix.
- ScMatrixRef xY = GetNewMat( nR, nR);
+ ScMatrixRef xY = GetNewMat( nR, nR, /*bEmpty*/true );
if (!xLU || !xY)
PushError( FormulaError::CodeOverflow);
else
@@ -1095,7 +1095,7 @@ void ScInterpreter::ScMatMult()
PushIllegalArgument();
else
{
- pRMat = GetNewMat(nC2, nR1);
+ pRMat = GetNewMat(nC2, nR1, /*bEmpty*/true);
if (pRMat)
{
double sum;
@@ -1135,7 +1135,7 @@ void ScInterpreter::ScMatTrans()
{
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- pRMat = GetNewMat(nR, nC);
+ pRMat = GetNewMat(nR, nC, /*bEmpty*/true);
if ( pRMat )
{
pMat->MatTrans(*pRMat);
@@ -1177,7 +1177,7 @@ static ScMatrixRef lcl_MatrixCalculation(
rMat2.GetDimensions(nC2, nR2);
nMinC = lcl_GetMinExtent( nC1, nC2);
nMinR = lcl_GetMinExtent( nR1, nR2);
- ScMatrixRef xResMat = pInterpreter->GetNewMat(nMinC, nMinR);
+ ScMatrixRef xResMat = pInterpreter->GetNewMat(nMinC, nMinR, /*bEmpty*/true);
if (xResMat)
{
for (i = 0; i < nMinC; i++)
@@ -1235,7 +1235,7 @@ ScMatrixRef ScInterpreter::MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef
pMat2->GetDimensions(nC2, nR2);
nMinC = lcl_GetMinExtent( nC1, nC2);
nMinR = lcl_GetMinExtent( nR1, nR2);
- ScMatrixRef xResMat = GetNewMat(nMinC, nMinR);
+ ScMatrixRef xResMat = GetNewMat(nMinC, nMinR, /*bEmpty*/true);
if (xResMat)
{
xResMat->MatConcat(nMinC, nMinR, pMat1, pMat2, *pFormatter, mrDoc.GetSharedStringPool());
@@ -1443,7 +1443,7 @@ void ScInterpreter::ScAmpersand()
}
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- ScMatrixRef pResMat = GetNewMat(nC, nR);
+ ScMatrixRef pResMat = GetNewMat(nC, nR, /*bEmpty*/true);
if (pResMat)
{
if (nGlobalError != FormulaError::NONE)
@@ -1556,7 +1556,7 @@ void ScInterpreter::ScMul()
fVal = fVal2;
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- ScMatrixRef pResMat = GetNewMat(nC, nR);
+ ScMatrixRef pResMat = GetNewMat(nC, nR, /*bEmpty*/true);
if (pResMat)
{
pMat->MulOp( fVal, *pResMat);
@@ -1633,7 +1633,7 @@ void ScInterpreter::ScDiv()
}
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- ScMatrixRef pResMat = GetNewMat(nC, nR);
+ ScMatrixRef pResMat = GetNewMat(nC, nR, /*bEmpty*/true);
if (pResMat)
{
pMat->DivOp( bFlag, fVal, *pResMat);
@@ -1700,7 +1700,7 @@ void ScInterpreter::ScPow()
}
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- ScMatrixRef pResMat = GetNewMat(nC, nR);
+ ScMatrixRef pResMat = GetNewMat(nC, nR, /*bEmpty*/true);
if (pResMat)
{
pMat->PowOp( bFlag, fVal, *pResMat);
@@ -1902,7 +1902,7 @@ void ScInterpreter::ScFrequency()
PushNoValue();
return;
}
- ScMatrixRef pResMat = GetNewMat(1, nBinSize+1);
+ ScMatrixRef pResMat = GetNewMat(1, nBinSize+1, /*bEmpty*/true);
if (!pResMat)
{
PushIllegalArgument();
@@ -2376,7 +2376,7 @@ bool ScInterpreter::CheckMatrix(bool _bLOG, sal_uInt8& nCase, SCSIZE& nCX,
}
else
{
- pMatX = GetNewMat(nCY, nRY);
+ pMatX = GetNewMat(nCY, nRY, /*bEmpty*/true);
nCX = nCY;
nRX = nRY;
if (!pMatX)
@@ -2479,9 +2479,9 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP)
ScMatrixRef pResMat;
if (bStats)
- pResMat = GetNewMat(K+1,5);
+ pResMat = GetNewMat(K+1,5, /*bEmpty*/true);
else
- pResMat = GetNewMat(K+1,1);
+ pResMat = GetNewMat(K+1,1, /*bEmpty*/true);
if (!pResMat)
{
PushError(FormulaError::CodeOverflow);
@@ -2608,13 +2608,13 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP)
{
::std::vector< double> aVecR(N); // for QR decomposition
// Enough memory for needed matrices?
- ScMatrixRef pMeans = GetNewMat(K, 1); // mean of each column
+ ScMatrixRef pMeans = GetNewMat(K, 1, /*bEmpty*/true); // mean of each column
ScMatrixRef pMatZ; // for Q' * Y , inter alia
if (bStats)
pMatZ = pMatY->Clone(); // Y is used in statistic, keep it
else
pMatZ = pMatY; // Y can be overwritten
- ScMatrixRef pSlopes = GetNewMat(1,K); // from b1 to bK
+ ScMatrixRef pSlopes = GetNewMat(1,K, /*bEmpty*/true); // from b1 to bK
if (!pMeans || !pMatZ || !pSlopes)
{
PushError(FormulaError::CodeOverflow);
@@ -2763,13 +2763,13 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP)
{
::std::vector< double> aVecR(N); // for QR decomposition
// Enough memory for needed matrices?
- ScMatrixRef pMeans = GetNewMat(1, K); // mean of each row
+ ScMatrixRef pMeans = GetNewMat(1, K, /*bEmpty*/true); // mean of each row
ScMatrixRef pMatZ; // for Q' * Y , inter alia
if (bStats)
pMatZ = pMatY->Clone(); // Y is used in statistic, keep it
else
pMatZ = pMatY; // Y can be overwritten
- ScMatrixRef pSlopes = GetNewMat(K,1); // from b1 to bK
+ ScMatrixRef pSlopes = GetNewMat(K,1, /*bEmpty*/true); // from b1 to bK
if (!pMeans || !pMatZ || !pSlopes)
{
PushError(FormulaError::CodeOverflow);
@@ -3030,13 +3030,13 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth)
}
ScMatrixRef pResMat; // size depends on nCase
if (nCase == 1)
- pResMat = GetNewMat(nCXN,nRXN);
+ pResMat = GetNewMat(nCXN,nRXN, /*bEmpty*/true);
else
{
if (nCase==2)
- pResMat = GetNewMat(1,nRXN);
+ pResMat = GetNewMat(1,nRXN, /*bEmpty*/true);
else
- pResMat = GetNewMat(nCXN,1);
+ pResMat = GetNewMat(nCXN,1, /*bEmpty*/true);
}
if (!pResMat)
{
@@ -3110,8 +3110,8 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth)
{
::std::vector< double> aVecR(N); // for QR decomposition
// Enough memory for needed matrices?
- ScMatrixRef pMeans = GetNewMat(K, 1); // mean of each column
- ScMatrixRef pSlopes = GetNewMat(1,K); // from b1 to bK
+ ScMatrixRef pMeans = GetNewMat(K, 1, /*bEmpty*/true); // mean of each column
+ ScMatrixRef pSlopes = GetNewMat(1,K, /*bEmpty*/true); // from b1 to bK
if (!pMeans || !pSlopes)
{
PushError(FormulaError::CodeOverflow);
@@ -3169,8 +3169,8 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth)
::std::vector< double> aVecR(N); // for QR decomposition
// Enough memory for needed matrices?
- ScMatrixRef pMeans = GetNewMat(1, K); // mean of each row
- ScMatrixRef pSlopes = GetNewMat(K,1); // row from b1 to bK
+ ScMatrixRef pMeans = GetNewMat(1, K, /*bEmpty*/true); // mean of each row
+ ScMatrixRef pSlopes = GetNewMat(K,1, /*bEmpty*/true); // row from b1 to bK
if (!pMeans || !pSlopes)
{
PushError(FormulaError::CodeOverflow);
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 98a0551c5261..750b42572706 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -1323,7 +1323,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
{
SCSIZE nC, nR;
pTMat->GetDimensions( nC, nR );
- ScMatrixRef pFcMat = GetNewMat( nC, nR );
+ ScMatrixRef pFcMat = GetNewMat( nC, nR, /*bEmpty*/true );
aETSCalc.GetForecastRange( pTMat, pFcMat );
if (aETSCalc.GetError() != FormulaError::NONE)
PushError( aETSCalc.GetError()); // explicitly push error, PushMatrix() does not
@@ -1336,7 +1336,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
{
SCSIZE nC, nR;
pTMat->GetDimensions( nC, nR );
- ScMatrixRef pPIMat = GetNewMat( nC, nR );
+ ScMatrixRef pPIMat = GetNewMat( nC, nR, /*bEmpty*/true );
if ( nSmplInPrd == 0 )
{
aETSCalc.GetEDSPredictionIntervals( pTMat, pPIMat, fPILevel );
@@ -1356,7 +1356,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType )
{
SCSIZE nC, nR;
pTypeMat->GetDimensions( nC, nR );
- ScMatrixRef pStatMat = GetNewMat( nC, nR );
+ ScMatrixRef pStatMat = GetNewMat( nC, nR, /*bEmpty*/true );
aETSCalc.GetStatisticValue( pTypeMat, pStatMat );
if (aETSCalc.GetError() != FormulaError::NONE)
PushError( aETSCalc.GetError()); // explicitly push error, PushMatrix() does not
More information about the Libreoffice-commits
mailing list