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

Eike Rathke erack at redhat.com
Fri Nov 4 13:21:19 UTC 2016


 sc/source/core/data/table3.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 2ba62a78151c3cd8a104b763f29432bb49de5e26
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Nov 4 14:20:23 2016 +0100

    sc-perf: eliminate unnecessary loops in ScTable::UpdateSelectionFunction()
    
    That looped unconditionally over all columns of a sheet just to let
    ScColumn::UpdateSelectionFunction() costly (by creating empty spans) decide
    that it doesn't have to do anything. This for *every* cell cursor movement or
    switching sheets et al. Instead, use the ScMarkData area to narrow down the
    range beforehand, which when travelling with the cell cursor is just one
    column.
    
    Change-Id: Ic60928d07bc6cec4f6d8491ab30b99d7b20b8490

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 311ac02..1336e04 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3404,7 +3404,20 @@ sal_Int32 ScTable::GetMaxNumberStringLen(
 void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark )
 {
     ScRangeList aRanges = rMark.GetMarkedRangesForTab( nTab );
-    for (SCCOL nCol = 0; nCol <= MAXCOL && !rData.bError; ++nCol)
+    ScRange aMarkArea( ScAddress::UNINITIALIZED );
+    if (rMark.IsMultiMarked())
+        rMark.GetMultiMarkArea( aMarkArea );
+    else if (rMark.IsMarked())
+        rMark.GetMarkArea( aMarkArea );
+    else
+    {
+        assert(!"ScTable::UpdateSelectionFunction - called without anything marked");
+        aMarkArea.aStart.SetCol(0);
+        aMarkArea.aEnd.SetCol(MAXCOL);
+    }
+    const SCCOL nStartCol = aMarkArea.aStart.Col();
+    const SCCOL nEndCol = aMarkArea.aEnd.Col();
+    for (SCCOL nCol = nStartCol; nCol <= nEndCol && !rData.bError; ++nCol)
     {
         if (pColFlags && ColHidden(nCol))
             continue;


More information about the Libreoffice-commits mailing list