sc/source/core/data/column.cxx | 9 +++++++++ 1 file changed, 9 insertions(+)
New commits: commit a3fb726f4972c5a869e778353c8c1c19f149c5ea Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri Dec 7 17:37:15 2018 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Fri Dec 14 16:25:03 2018 +0100 optimize expensive EndListener() calls (tdf#102364) The document has a large (1M cells) column, and when replacing old cells with new cells during undo as described in the bugreport the repeated calls to EndListener() from ScColumn::DetachFormulaCell() get quite costly. Optimize this by doing a single EndListeningFormulaCells() call. Change-Id: If51dacdfbe876134de956dbc6bbd73e97d9686ff Reviewed-on: https://gerrit.libreoffice.org/64781 Tested-by: Jenkins Reviewed-by: Kohei Yoshida <libreoff...@kohei.us> Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index bfd11e038bf0..0c151a70ac65 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1633,6 +1633,15 @@ public: sc::formula_block::const_iterator itEnd = it; std::advance(itEnd, nDataSize); + if(nDataSize > 1024 && (mnCopyFlags & InsertDeleteFlags::FORMULA) != InsertDeleteFlags::NONE) + { + // If the column to be replaced contains a long formula group (tdf#102364), there can + // be so many listeners in a single vector that the quadratic cost of repeatedly removing + // the first element becomes very high. Optimize this by removing them in one go. + sc::EndListeningContext context(*mrDestCol.GetDoc()); + mrDestCol.EndListeningFormulaCells( context, nRow, nRow + nDataSize - 1, nullptr, nullptr ); + } + for (; it != itEnd; ++it, ++nRow) cloneFormulaCell(nRow, **it); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits