summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/colcontainer.cxx5
-rw-r--r--sc/source/core/data/table2.cxx2
2 files changed, 4 insertions, 3 deletions
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 9dac5733fd41..6f713ca9f957 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -502,6 +502,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);