summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-12-19 17:51:53 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-01-06 04:23:16 +0000
commit1ae0e6938b58cb94403aa71eeaf73ef9785b38e8 (patch)
tree36a7e75435e25c70a9a62e2530bd53449467284d /sc/source
parent85c632cf640a23be3f760d42599f905b24772280 (diff)
Check number of cells referenced by group instead of group size
It's more relevant when deciding whether to use OpenCL or not. Note that we won't use OpenCL for a single formula cell, no matter how large a calculation it invokes (like =SUM(A1:A1000000), for instance), as a single cell is not a group. Change-Id: I66b03c197431c2b4cef96f46b010d99d3e0624fc Reviewed-on: https://gerrit.libreoffice.org/13597 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/formulacell.cxx9
-rw-r--r--sc/source/core/tool/token.cxx27
2 files changed, 35 insertions, 1 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index bc9ffbe4940c..daefcc6ab2b7 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,13 @@ SCROW ScFormulaCell::GetSharedLength() const
return mxGroup ? mxGroup->mnLength : 0;
}
+sal_Int32 ScFormulaCell::GetWeight() const
+{
+ if (!mxGroup)
+ return pCode->GetWeight();
+ return GetSharedLength() * GetSharedCode()->GetWeight();
+}
+
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..89a33e6f2fce 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(0);
+
+ 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