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

New commits:
commit f4c43f8fc8c08f9ad0a63504a3067eca6b8b2c00
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: Fri Jun 17 14:27:46 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>
    (cherry picked from commit 7689bf445264d1b54038ec0b8d134c26847af40f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135552
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index e65aa194f9f7..43dcd6abee20 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