summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@centrum.cz>2022-02-20 02:33:36 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-20 08:01:40 +0100
commitfdcea8ccc8236b0975ac9c85dcabf9c663e4b627 (patch)
treec53bd1d4bdba90cf92ec46ccebd3c85530347e92
parent131710cba68e46c175babbd20c810e7fc2fb811f (diff)
make CollectCellAction sort cells by cell address (tdf#119083)
Many calc algorithms perform better if they process cells ordered by tab,col,row. In the case of tdf#119083 it's ScDocument::TrackFormulas(). Change-Id: I1eedefc0130f5cf95feb84a4160b7599d3a09fd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130205 Tested-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/source/core/tool/grouparealistener.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sc/source/core/tool/grouparealistener.cxx b/sc/source/core/tool/grouparealistener.cxx
index 4c92475d9a3f..39b92625b5b8 100644
--- a/sc/source/core/tool/grouparealistener.cxx
+++ b/sc/source/core/tool/grouparealistener.cxx
@@ -63,8 +63,14 @@ public:
void swapCells( std::vector<ScFormulaCell*>& rCells )
{
- // Remove duplicate before the swap.
- std::sort(maCells.begin(), maCells.end());
+ // Remove duplicate before the swap. Take care to sort them by tab,col,row before sorting by pointer,
+ // as many calc algorithms perform better if cells are processed in this order.
+ std::sort(maCells.begin(), maCells.end(), [](const ScFormulaCell* cell1, const ScFormulaCell* cell2)
+ {
+ if( cell1->aPos != cell2->aPos )
+ return cell1->aPos < cell2->aPos;
+ return cell1 < cell2;
+ });
std::vector<ScFormulaCell*>::iterator it = std::unique(maCells.begin(), maCells.end());
maCells.erase(it, maCells.end());