summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-12-16 15:04:19 +0100
committerEike Rathke <erack@redhat.com>2017-12-16 21:02:37 +0100
commitda81ec6862490a87bc240edb81c0a9b5fd04a1b3 (patch)
treeade5524d8c7fc7a821a46cceb25465752aafa151
parent0bf4fd6ce0b8bfe8349e95571ad09e94cc3d1fef (diff)
Do not recalculate the same weight over and over again, tdf#114251 related
Remember it at the group so if for some reason the group is not calculated as group then the individual cells of the group don't iterate over the RPN again to calculate the same value. This does not solve tdf#114251 in any way, just side-cars. Change-Id: Ia26d4a7fe608d8aaa30686ce95c1caa25da02469 Reviewed-on: https://gerrit.libreoffice.org/46601 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/inc/formulacell.hxx1
-rw-r--r--sc/source/core/data/formulacell.cxx12
2 files changed, 11 insertions, 2 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index cdb67a3e27fc..867bb89692d2 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -65,6 +65,7 @@ public:
ScTokenArray* mpCode;
ScFormulaCell *mpTopCell;
SCROW mnLength; // How many of these do we have ?
+ sal_Int32 mnWeight;
short mnFormatType;
bool mbInvariant:1;
bool mbSubTotal:1;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 0d89476ec0a2..071ec5b41923 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -523,6 +523,7 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
mpCode(nullptr),
mpTopCell(nullptr),
mnLength(0),
+ mnWeight(0),
mnFormatType(css::util::NumberFormat::NUMBER),
mbInvariant(false),
mbSubTotal(false),
@@ -3875,6 +3876,7 @@ void ScFormulaCell::SetCellGroup( const ScFormulaCellGroupRef &xRef )
mxGroup = xRef;
pCode = mxGroup->mpCode;
+ mxGroup->mnWeight = 0; // invalidate
}
ScFormulaCell::CompareState ScFormulaCell::CompareByTokenArray( const ScFormulaCell& rOther ) const
@@ -4919,12 +4921,18 @@ sal_Int32 ScFormulaCell::GetWeight() const
{
if (!mxGroup)
return 1;
+
+ if (mxGroup->mnWeight > 0)
+ return mxGroup->mnWeight;
+
double nSharedCodeWeight = GetSharedCode()->GetWeight();
double nResult = nSharedCodeWeight * GetSharedLength();
if (nResult < SAL_MAX_INT32)
- return nResult;
+ mxGroup->mnWeight = nResult;
else
- return SAL_MAX_INT32;
+ mxGroup->mnWeight = SAL_MAX_INT32;
+
+ return mxGroup->mnWeight;
}
ScTokenArray* ScFormulaCell::GetSharedCode()