[Libreoffice-commits] core.git: sc/source

Luboš Luňák l.lunak at collabora.com
Thu May 24 15:55:48 UTC 2018


 sc/source/core/data/column2.cxx |   37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

New commits:
commit 3a801799536e6870f2fb111b1cc00b9575a35a39
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Thu May 24 14:38:59 2018 +0200

    optimize ScColumn::HandleRefArrayForParallelism()
    
    Change-Id: I53b7f514be2e015445eb9cb0471c22d41c464e4e
    Reviewed-on: https://gerrit.libreoffice.org/54767
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 0a62cb10506d..79654808a14f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2818,14 +2818,37 @@ bool ScColumn::HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2 )
     if (nRow1 > nRow2)
         return false;
 
-    for (auto i = nRow1; i <= nRow2; ++i)
+    std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow1);
+    sc::CellStoreType::const_iterator it = aPos.first;
+    size_t nOffset = aPos.second;
+    SCROW nRow = nRow1;
+    for (;it != maCells.end() && nRow <= nRow2; ++it, nOffset = 0)
     {
-        auto aCell = GetCellValue(i);
-        if (aCell.meType == CELLTYPE_FORMULA)
-            aCell.mpFormula->MaybeInterpret();
-        // These require EditEngine (in ScEditUtils::GetString()), which is probably too complex for use in threads.
-        if (aCell.meType == CELLTYPE_EDIT)
-            return false;
+        switch( it->type )
+        {
+            case sc::element_type_edittext:
+                // These require EditEngine (in ScEditUtils::GetString()), which is probably
+                // too complex for use in threads.
+                return false;
+            case sc::element_type_formula:
+            {
+                size_t nRowsToRead = nRow2 - nRow + 1;
+                size_t nEnd = std::min(it->size, nOffset+nRowsToRead); // last row + 1
+                sc::formula_block::const_iterator itCell = sc::formula_block::begin(*it->data);
+                std::advance(itCell, nOffset);
+                for (size_t i = nOffset; i < nEnd; ++itCell, ++i)
+                {
+                    // Loop inside the formula block.
+                    (*itCell)->MaybeInterpret();
+                }
+                nRow += nEnd;
+                break;
+            }
+            default:
+                // Skip this block.
+                nRow += it->size - nOffset;
+                continue;
+        }
     }
 
     return true;


More information about the Libreoffice-commits mailing list