sc/inc/formulacell.hxx | 1 + sc/source/core/data/formulacell.cxx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
New commits: commit da81ec6862490a87bc240edb81c0a9b5fd04a1b3 Author: Eike Rathke <[email protected]> Date: Sat Dec 16 15:04:19 2017 +0100 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 <[email protected]> Tested-by: Eike Rathke <[email protected]> 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() _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
