From c50d8bf596f527bb53b86dd04da652ed72f2c549 Mon Sep 17 00:00:00 2001 From: Supreme Aryal Date: Thu, 4 Dec 2014 02:14:06 -0500 Subject: 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 Tested-by: Eike Rathke --- sc/source/core/data/table3.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sc') 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()); -- cgit