Kaydet (Commit) a3fb726f authored tarafından Luboš Luňák's avatar Luboš Luňák Kaydeden (comit) Eike Rathke

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: 's avatarKohei Yoshida <libreoffice@kohei.us>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst 77ca13a2
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment