diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-02-04 16:19:38 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-02-04 20:58:32 +0200 |
commit | 3c50f98dc266b42ffe9cdc8843d21e4a47a16bcb (patch) | |
tree | 239cba854f2f22e733e8f3b3e2a9b49af65af5f5 /sc | |
parent | 8d8b5dbb2212b85abe60d4a477c3f65e87e74797 (diff) |
Check number of cells referenced by group instead of group size
Put using it in #if 0 for now, though.
This reverts commit 1fd902d4b851c534cf7473dd13983fc2c46500ed
Change-Id: I7bb3efdc594bf7f1a61b037bf3488dae4ca119c9
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/formulacell.hxx | 4 | ||||
-rw-r--r-- | sc/inc/tokenarray.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 27 |
4 files changed, 46 insertions, 1 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 86b8045ee1d6..746ca5505c32 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -410,6 +410,10 @@ public: bool IsSharedTop() const; SCROW GetSharedTopRow() const; SCROW GetSharedLength() const; + + // An estimate of the number of cells referenced by the formula + sal_Int32 GetWeight() const; + ScTokenArray* GetSharedCode(); const ScTokenArray* GetSharedCode() const; diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index 07f344b5bfce..ad61ef3cdc87 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -59,6 +59,9 @@ public: virtual ~ScTokenArray(); ScTokenArray* Clone() const; /// True copy! + // An estimate of the number of cells referenced by the token array + sal_Int32 GetWeight() const; + void GenHash(); size_t GetHash() const { return mnHashValue;} diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index bc9ffbe4940c..98bb56878e4a 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3750,7 +3750,7 @@ bool ScFormulaCell::InterpretFormulaGroup() if (mxGroup->meCalcState == sc::GroupCalcDisabled) return false; - if (GetSharedLength() < ScInterpreter::GetGlobalConfig().mnOpenCLMinimumFormulaGroupSize) + if (GetWeight() < ScInterpreter::GetGlobalConfig().mnOpenCLMinimumFormulaGroupSize) { mxGroup->meCalcState = sc::GroupCalcDisabled; return false; @@ -4128,6 +4128,17 @@ SCROW ScFormulaCell::GetSharedLength() const return mxGroup ? mxGroup->mnLength : 0; } +sal_Int32 ScFormulaCell::GetWeight() const +{ +#if 0 + if (!mxGroup) + return pCode->GetWeight(); + return GetSharedLength() * GetSharedCode()->GetWeight(); +#else + return GetSharedLength(); +#endif +} + ScTokenArray* ScFormulaCell::GetSharedCode() { return mxGroup ? mxGroup->mpCode : NULL; diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 8816b87df833..ee55b074bd59 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1412,6 +1412,33 @@ bool ScTokenArray::ImplGetReference( ScRange& rRange, const ScAddress& rPos, boo return bIs; } +sal_Int32 ScTokenArray::GetWeight() const +{ + sal_Int32 result(1); + + FormulaToken** p = pCode; + FormulaToken** pEnd = p + static_cast<size_t>(nLen); + for (; p != pEnd; ++p) + { + switch ((*p)->GetType()) + { + case svDoubleRef : + case svExternalDoubleRef: + { + const ScComplexRefData& rRef = *(*p)->GetDoubleRef(); + result += ( (rRef.Ref2.Row() - rRef.Ref1.Row() + 1) * (rRef.Ref2.Col() - rRef.Ref1.Col() + 1) ); + } + break; + default: + break; + } + } + // Just print out the this pointer. It turns out to be quite complicated to get + // a symbolic printout of the ScTokenArray here. + SAL_INFO("sc.token", "GetWeight(" << this << "): " << result); + return result; +} + namespace { // we want to compare for similar not identical formulae |