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 3f92f7dc8983b04db104eb0f00aaad5c6810c520 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. Change-Id: Iee94ca9dae00a2c33c0306cdf41bd7832e7ecd03 diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 1c40939..2ac8412 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -213,6 +213,7 @@ public: sal_uInt16 GetMatrixEdge( ScAddress& rOrgPos ) const; sal_uInt16 GetErrCode(); // interpret first if necessary sal_uInt16 GetRawError(); // don't interpret, just return code or result error + 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 3fa15cf..b5b0e4f 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 68d242d..15652b5 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1934,6 +1934,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