sc/inc/formulacell.hxx | 1 + sc/source/core/data/dociter.cxx | 8 +++----- sc/source/core/data/formulacell.cxx | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-)
New commits: commit ffdb8faf9a7f942ca4c9f74710cc4d07db9981cf Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Jun 24 20:46:37 2013 -0400 Avoid redundant if branches. Instead of calling GetErrCode(), IsValue() and GetValue() individually, do it all at once. This alone cuts about 12 seconds off in the calculation involving a large spreadsheet document. Conflicts: sc/inc/formulacell.hxx Change-Id: Iee94ca9dae00a2c33c0306cdf41bd7832e7ecd03 diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 196e6bf..f5fa1c6 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -216,6 +216,7 @@ public: sal_uLong GetFormatIndex() const { return nFormatIndex; } void GetFormatInfo( short& nType, sal_uLong& nIndex ) const { nType = nFormatType; nIndex = nFormatIndex; } + bool GetErrorOrValue( sal_uInt16& rErr, double& rVal ); sal_uInt8 GetMatrixFlag() const { return cMatrixFlag; } ScTokenArray* GetCode() const { return pCode; } diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 1cdc52c..298bb77 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -220,18 +220,16 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) break; case sc::element_type_formula: { - ScFormulaCell* pCell = sc::formula_block::at(*maCurPos.first->data, maCurPos.second); - if (bSubTotal && pCell->IsSubTotal()) + ScFormulaCell& rCell = *sc::formula_block::at(*maCurPos.first->data, maCurPos.second); + if (bSubTotal && rCell.IsSubTotal()) { // Skip subtotal formula cells. IncPos(); break; } - rErr = pCell->GetErrCode(); - if (rErr || pCell->IsValue()) + if (rCell.GetErrorOrValue(rErr, rValue)) { - rValue = pCell->GetValue(); bNumValid = false; return true; // Found it! } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 3ce95d4..01f7488 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1949,6 +1949,25 @@ sal_uInt16 ScFormulaCell::GetRawError() return aResult.GetResultError(); } +bool ScFormulaCell::GetErrorOrValue( sal_uInt16& rErr, double& rVal ) +{ + MaybeInterpret(); + + rErr = pCode->GetCodeError(); + if (rErr) + return true; + + rErr = aResult.GetResultError(); + if (rErr) + return true; + + if (!aResult.IsValue()) + return false; + + rVal = aResult.GetDouble(); + return true; +} + bool ScFormulaCell::HasOneReference( ScRange& r ) const { pCode->Reset(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits