[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/inc sc/source

Eike Rathke erack at redhat.com
Mon Dec 18 11:47:49 UTC 2017


 sc/inc/formulacell.hxx              |    1 +
 sc/source/core/data/formulacell.cxx |   12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 14ce530d467a21d2d7fdae5272c5cc4b83104bdc
Author: Eike Rathke <erack at redhat.com>
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 <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit da81ec6862490a87bc240edb81c0a9b5fd04a1b3)
    Reviewed-on: https://gerrit.libreoffice.org/46612
    Tested-by: Jenkins <ci at libreoffice.org>

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()


More information about the Libreoffice-commits mailing list