diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-06-10 17:39:46 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-06-11 06:22:12 +0200 |
commit | 7689bf445264d1b54038ec0b8d134c26847af40f (patch) | |
tree | 71f8e97edf0a8dd240e26f052488a7440956e7f9 /sc | |
parent | e0c5f8b4f6152d19044f998edc293b4bb636e66c (diff) |
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.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/table1.cxx | 24 |
1 files changed, 12 insertions, 12 deletions
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 ? |