[Libreoffice-commits] core.git: Branch 'feature/fixes38' - sc/source
László Németh
laszlo.nemeth at collabora.com
Fri Mar 3 13:08:19 UTC 2017
sc/source/core/tool/interpr6.cxx | 91 +++++++++++++--------------------------
1 file changed, 32 insertions(+), 59 deletions(-)
New commits:
commit 83da402fbf02f5aa778b6d3554275b14f40d8bc5
Author: László Németh <laszlo.nemeth at collabora.com>
Date: Fri Mar 3 14:05:46 2017 +0100
Revert "Adapt FuncSum to vectorize better."
This reverts commit 258e48d6d9c0d2ea9621b248239c0e1708a85cda.
Change-Id: I96ce1e63d2d0c300cbe25afdd9c139b2d76464eb
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 78d6f47..fedf026 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -203,6 +203,8 @@ double ScInterpreter::GetGammaDist( double fX, double fAlpha, double fLambda )
return GetLowRegIGamma( fAlpha, fX / fLambda);
}
+namespace {
+
class NumericCellAccumulator
{
double mfFirst;
@@ -212,69 +214,38 @@ class NumericCellAccumulator
public:
NumericCellAccumulator() : mfFirst(0.0), mfRest(0.0), mnError(0) {}
- void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize)
+ void operator() (size_t, double fVal)
{
- switch (rNode.type)
- {
- case sc::element_type_numeric:
- {
- const double *p = &sc::numeric_block::at(*rNode.data, nOffset);
- size_t i = 0;
-
- // Store the first non-zero value in mfFirst (for some reason).
- if (!mfFirst)
- {
- for (i = 0; i < nDataSize; ++i)
- {
- if (!mfFirst)
- mfFirst = p[i];
- else
- break;
- }
- }
- p += i;
- nDataSize -= i;
- if (nDataSize == 0)
- return;
-
- sc::ArraySumFunctor functor(p, nDataSize);
-
- mfRest += functor();
- break;
- }
+ if ( !mfFirst )
+ mfFirst = fVal;
+ else
+ mfRest += fVal;
+ }
- case sc::element_type_formula:
- {
- sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data);
- std::advance(it, nOffset);
- sc::formula_block::const_iterator itEnd = it;
- std::advance(itEnd, nDataSize);
- for (; it != itEnd; ++it)
- {
- double fVal = 0.0;
- sal_uInt16 nErr = 0;
- ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*(*it));
- if (!rCell.GetErrorOrValue(nErr, fVal))
- // The cell has neither error nor value. Perhaps string result.
- continue;
+ void operator() (size_t, const ScFormulaCell* pCell)
+ {
+ if (mnError)
+ // Skip all the rest if we have an error.
+ return;
- if (nErr)
- {
- // Cell has error - skip all the rest
- mnError = nErr;
- return;
- }
+ double fVal = 0.0;
+ sal_uInt16 nErr = 0;
+ ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*pCell);
+ if (!rCell.GetErrorOrValue(nErr, fVal))
+ // The cell has neither error nor value. Perhaps string result.
+ return;
- if ( !mfFirst )
- mfFirst = fVal;
- else
- mfRest += fVal;
- }
- }
- break;
- default:
- ;
+ if (nErr)
+ {
+ // Cell has error.
+ mnError = nErr;
+ return;
}
+
+ if ( !mfFirst )
+ mfFirst = fVal;
+ else
+ mfRest += fVal;
}
sal_uInt16 getError() const { return mnError; }
@@ -376,7 +347,7 @@ public:
return;
NumericCellAccumulator aFunc;
- maPos.miCellPos = sc::ParseBlock(maPos.miCellPos, mpCol->GetCellStore(), aFunc, nRow1, nRow2);
+ maPos.miCellPos = sc::ParseFormulaNumeric(maPos.miCellPos, mpCol->GetCellStore(), nRow1, nRow2, aFunc);
mnError = aFunc.getError();
if (mnError)
return;
@@ -459,6 +430,8 @@ void IterateMatrix(
}
}
+}
+
double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
{
short nParamCount = GetByte();
More information about the Libreoffice-commits
mailing list