Make MaybeInterpret, NeedsInterpret, IsDirtyOrInTableOpDirty inline

because they are in the hot path of the most common workload.
For example, in SUM(A1:A50000) where column A is itself a
formula-group, in threaded mode(default) A1:A50000 will already
be evaluated, so cost to calling MaybeInterpret/NeedsInterpret etc
should be as minimal as possible.

Change-Id: Ie15c1483573391a718fb3af14cba3c798323363d
Reviewed-on: https://gerrit.libreoffice.org/63064
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Dennis Francis
2018-11-08 10:03:44 +05:30
committed by Dennis Francis
parent 270e76f6eb
commit eb51a44ca4
2 changed files with 27 additions and 30 deletions

View File

@@ -27,6 +27,7 @@
#include "types.hxx"
#include "interpretercontext.hxx"
#include "document.hxx"
#include "formulalogger.hxx"
#include "formularesult.hxx"
@@ -222,7 +223,12 @@ public:
void SetDirtyAfterLoad();
void ResetTableOpDirtyVar();
void SetTableOpDirty();
bool IsDirtyOrInTableOpDirty() const;
bool IsDirtyOrInTableOpDirty() const
{
return bDirty || (bTableOpDirty && pDocument->IsInInterpreterTableOp());
}
bool GetDirty() const { return bDirty; }
void ResetDirty();
bool NeedsListening() const { return bNeedListening; }
@@ -414,9 +420,27 @@ public:
/** Determines whether or not the result string contains more than one paragraph */
bool IsMultilineResult();
bool NeedsInterpret() const;
bool NeedsInterpret() const
{
if (bIsIterCell)
// Shortcut to force return of current value and not enter Interpret()
// as we're looping over all iteration cells.
return false;
void MaybeInterpret();
if (!IsDirtyOrInTableOpDirty())
return false;
return (pDocument->GetAutoCalc() || (cMatrixFlag != ScMatrixMode::NONE));
}
void MaybeInterpret()
{
if (NeedsInterpret())
{
assert(!pDocument->IsThreadedGroupCalcInProgress());
Interpret();
}
}
/**
* Turn a non-grouped cell into the top of a grouped cell.

View File

@@ -2517,11 +2517,6 @@ void ScFormulaCell::SetTableOpDirty()
}
}
bool ScFormulaCell::IsDirtyOrInTableOpDirty() const
{
return bDirty || (bTableOpDirty && pDocument->IsInInterpreterTableOp());
}
void ScFormulaCell::SetResultDouble( double n )
{
aResult.SetDouble(n);
@@ -2652,28 +2647,6 @@ bool ScFormulaCell::IsMultilineResult()
return false;
}
bool ScFormulaCell::NeedsInterpret() const
{
if (bIsIterCell)
// Shortcut to force return of current value and not enter Interpret()
// as we're looping over all iteration cells.
return false;
if (!IsDirtyOrInTableOpDirty())
return false;
return (pDocument->GetAutoCalc() || (cMatrixFlag != ScMatrixMode::NONE));
}
void ScFormulaCell::MaybeInterpret()
{
if (NeedsInterpret())
{
assert(!pDocument->IsThreadedGroupCalcInProgress());
Interpret();
}
}
bool ScFormulaCell::IsHyperLinkCell() const
{
return pCode && pCode->IsHyperLink();