summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-06-24 20:46:37 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-06-27 15:47:53 -0400
commitf5357308c4f8823836ebd17dd24c51729322be32 (patch)
tree317ec2282a58068d62f8be2f8a94967a1a3e54c4 /sc
parentdb56d99f7b66c9f3fe38581829077e7008174c7b (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/formulacell.hxx1
-rw-r--r--sc/source/core/data/dociter.cxx8
-rw-r--r--sc/source/core/data/formulacell.cxx19
3 files changed, 23 insertions, 5 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 1c4093974955..2ac841266405 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 507656959ec4..08d7dbc2f6c2 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 f57da6fdef5e..463bf4ad1a8a 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();