summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSupreme Aryal <supremearyal@gmail.com>2014-12-04 02:14:06 -0500
committerEike Rathke <erack@redhat.com>2014-12-05 16:56:01 +0000
commitc50d8bf596f527bb53b86dd04da652ed72f2c549 (patch)
tree1b4c3e0a440b89a18e7ad8bdd5e9a33144dd964e /sc
parentcf6445c16a8fe7e8fb43a7ffdc4fbcdd753209bb (diff)
Fix high memory usage when sorting cells in Calc. (fdo#81501)
Empty columns were being unnecessarily included in the sorting range which caused extra allocation. This happens when you select the entire sheet to sort. There was already code to skip empty trailing cells in rows but not to skip empty columns. Change-Id: Ieac22647bb13165cbf66cb1a93f567e5169fff6a Reviewed-on: https://gerrit.libreoffice.org/13294 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table3.cxx2
1 files changed, 2 insertions, 0 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 5ee2ada89452..1a2a5182e620 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1542,6 +1542,8 @@ void ScTable::Sort(
if (rSortParam.bByRow)
{
+ while (aSortParam.nCol2 > aSortParam.nCol1 && aCol[aSortParam.nCol2].IsEmptyData())
+ --aSortParam.nCol2;
SCROW nLastRow = 0;
for (SCCOL nCol = aSortParam.nCol1; nCol <= aSortParam.nCol2; nCol++)
nLastRow = std::max(nLastRow, aCol[nCol].GetLastDataPos());