sc/source/core/data/colcontainer.cxx |    5 ++---
 sc/source/core/data/table2.cxx       |    2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit d891af6d9b876b172a77df5315c0a176f8dbdc6f
Author:     Noel Grandin <noelgran...@collabora.co.uk>
AuthorDate: Tue Jan 30 13:51:20 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 31 20:58:28 2024 +0100

    tdf#159131 Calc is laggy when moving a line (row)
    
    revert  69910b540ae5140123fd2d4d67a9d338f980db53 and
    add a couple of pre-emptive reserve calls, to prevent repeated
    resizing.
    
    I'm not sure why the above commit causes trouble on Windows, but
    not Linux, something in the std::vector::reserve implementation
    no doubt.
    
    Change-Id: I858303a0a1e12d204fd3bbccc6c6c7ce57564e5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162746
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 21dd07f95d7dcb95f243753306108c18d9ba115a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162726
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/colcontainer.cxx 
b/sc/source/core/data/colcontainer.cxx
index f6ef8ff7da17..a0a9d845772f 100644
--- a/sc/source/core/data/colcontainer.cxx
+++ b/sc/source/core/data/colcontainer.cxx
@@ -47,10 +47,9 @@ void ScColContainer::Clear()
 void ScColContainer::resize( ScSheetLimits const & rSheetLimits, const size_t 
aNewColSize )
 {
     size_t aOldColSize = aCols.size();
-    if (aNewColSize > aCols.capacity())
-        aCols.reserve( aNewColSize );
+    aCols.resize( aNewColSize );
     for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol )
-        aCols.emplace_back(new ScColumn(rSheetLimits));
+        aCols[nCol].reset(new ScColumn(rSheetLimits));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a871a1fb82c8..6d7c5b0ac874 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -503,6 +503,7 @@ void ScTable::CopyToClip(
 
     nCol2 = ClampToAllocatedColumns(nCol2);
 
+    pTable->CreateColumnIfNotExists(nCol2);  // prevent repeated resizing
     for ( SCCOL i = nCol1; i <= nCol2; i++)
         aCol[i].CopyToClip(rCxt, nRow1, nRow2, 
pTable->CreateColumnIfNotExists(i));  // notes are handled at column level
 
@@ -1351,6 +1352,7 @@ void ScTable::CopyToTable(
         // can lead to repetitive splitting and rejoining of the same formula 
group, which can get
         // quadratically expensive with large groups. So do the grouping just 
once at the end.
         sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, 
true );
+        pDestTab->CreateColumnIfNotExists(ClampToAllocatedColumns(nCol2)); // 
avoid repeated resizing
         for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++)
             aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bToUndoDoc ? nFlags : 
nTempFlags, bMarked,
                                  pDestTab->CreateColumnIfNotExists(i), 
pMarkData, bAsLink, bGlobalNamesToLocal);

Reply via email to