diff options
author | Eike Rathke <erack@redhat.com> | 2017-12-16 15:04:19 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-12-18 12:44:40 +0100 |
commit | 14ce530d467a21d2d7fdae5272c5cc4b83104bdc (patch) | |
tree | b02542e58d3b2be8b4d669e3ec41206ab94b8228 | |
parent | b4f8bb32bc016880cac007d5e15610de16fe3cbc (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>
(cherry picked from commit da81ec6862490a87bc240edb81c0a9b5fd04a1b3)
Reviewed-on: https://gerrit.libreoffice.org/46612
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sc/inc/formulacell.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index e75416de8e56..09d26b232950 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 989919b2886b..1068f25ff5b2 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() |