summaryrefslogtreecommitdiff
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 20:00:14 +0100
commitbc3755e041a6cdb678fb8c8093beb6b3a8e3f0e0 (patch)
tree4074c31807a5323dd434aa828fa4d3555689b3bb
parent4469ac71fe0aadf498db542b4e5da6212316d809 (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> (cherry picked from commit c50d8bf596f527bb53b86dd04da652ed72f2c549)
-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 d4c0aa00590d..63b3df05e23d 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1541,6 +1541,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());