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:54:02 +0200 |
commit | fab297c7945b51964627aa16a0b0019442d27a66 (patch) | |
tree | c57b564d9f568819296051c7561f7f5959c424bf /sc | |
parent | 4b269ecb7a699318b067eb64c464460b1783d3d2 (diff) |
Check number of cells referenced by group instead of group size
Put using it in #if 0 for now, though.
This reverts commit 2021275f8fc33d9917d5fef58959a95da1dc7e6f.
Change-Id: Ia6541df12ee97747badbbedd758873688190b00c
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 3803a468f7f3..c3a8f0e0f997 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -411,6 +411,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 5d6593d6f8f1..ab1e9419042b 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -60,6 +60,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 3939c0457287..d591870eca9f 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3766,7 +3766,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; @@ -4144,6 +4144,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 4312f5582707..e7e6ecefd420 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1417,6 +1417,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 |