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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 11 06:43:38 UTC 2020


 sc/source/core/tool/interpr5.cxx |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit 44a56e277f7e4d222767fa82f0bce2e7f51be6ca
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jun 10 13:46:09 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jun 11 08:43:08 2020 +0200

    tdf#133858 opening spreadsheet with large array formula takes 10 mins
    
    the spreadsheet has lots of SUM(IF over a whole column.
    
    Which results in us allocating a matrix with 1 million rows, which is
    rather slow to process.
    
    So reduce the matrix to the data that is actually there.
    
    We can only do this for some opcodes, because other opcodes act
    differently when referencing empty space, so for now I only perform this
    optimisation for the opcode in use in this spreadsheet.
    
    This takes the load time from 5m to 3s on my machine.
    
    Change-Id: I41fe9afcb0fbdf2a928a19c44a0f291a1247a41c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96022
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 9a5f2961b085ce2f23ecdf0a03d1114bacac8e2c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96042

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 685a2cfe8689..eeb3d71c094d 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -325,6 +325,15 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
         return nullptr;
     }
 
+    // Clamp the size of the matrix to rows which actually contain data.
+    // For e.g. SUM(IF over an entire column, this can make a big difference.
+    // Limit to ocEqual opcode for now, some opcodes behaviour differently if the
+    // input has empty space.
+    if (nTab1 == nTab2 && pCur->GetOpCode() == ocEqual)
+    {
+        pDok->ShrinkToDataArea(nTab1, nCol1, nRow1, nCol2, nRow2);
+    }
+
     SCSIZE nMatCols = static_cast<SCSIZE>(nCol2 - nCol1 + 1);
     SCSIZE nMatRows = static_cast<SCSIZE>(nRow2 - nRow1 + 1);
 


More information about the Libreoffice-commits mailing list