sc/source/core/data/table1.cxx |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 7689bf445264d1b54038ec0b8d134c26847af40f
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Jun 10 17:39:46 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Sat Jun 11 06:22:12 2022 +0200

    find last data row before searching for first data row
    
    GetLastDataRow() is more efficient than iterating every cell
    with HasDataAt(), so first reduce the row range from the end
    (in case the whole range is empty cells it's just one call).
    
    Change-Id: Idc494795f68492ed8b05b2cd575598a9c5868b7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135605
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 4a293f5068de..0eaf10c786da 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1118,6 +1118,18 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, 
SCCOL& rStartCol, SCROW& rS
 
     if (!bColumnsOnly)
     {
+        while (rStartRow < rEndRow)
+        {
+            SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, 
pDataAreaExtras);
+            if (0 <= nLastDataRow && nLastDataRow < rEndRow)
+            {
+                rEndRow = std::max( rStartRow, nLastDataRow);
+                o_bShrunk = true;
+            }
+            else
+                break;  // while
+        }
+
         if (!bStickyTopRow)
         {
             while (rStartRow < rEndRow)
@@ -1137,18 +1149,6 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, 
SCCOL& rStartCol, SCROW& rS
                     break;  // while
             }
         }
-
-        while (rStartRow < rEndRow)
-        {
-            SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, 
pDataAreaExtras);
-            if (0 <= nLastDataRow && nLastDataRow < rEndRow)
-            {
-                rEndRow = std::max( rStartRow, nLastDataRow);
-                o_bShrunk = true;
-            }
-            else
-                break;  // while
-        }
     }
 
     return rStartCol != rEndCol || (bColumnsOnly ?

Reply via email to