diff options
author | Eike Rathke <erack@redhat.com> | 2017-06-07 00:49:47 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-06-07 00:50:54 +0200 |
commit | 59c9d0653cc42560af48269bb8dee2c2b0b20f68 (patch) | |
tree | 0b3e59964335cb39d40c1ae1adc04cec4ec14b38 | |
parent | 90a286ad4e2c35ac98a8100a27777bd33d71f2c7 (diff) |
Perf-sc: tdf#100709 Use a "one and a half" alloc strategy for ScMarkArray
ScMarkArray::SetMarkArea()
before, Ir: 3 059 572 314
after, Ir: 1 195 743 815
ScDocShell::Load()
before, Ir: 17 337 645 368
after, Ir: 15 497 093 406
Change-Id: I83959f0dfcf6480781a44b5cfc36242a5c35ebd4
-rw-r--r-- | sc/source/core/data/markarr.cxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx index 52b7597fe1cd..248ddd0cb4c0 100644 --- a/sc/source/core/data/markarr.cxx +++ b/sc/source/core/data/markarr.cxx @@ -121,7 +121,16 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ) SCSIZE nNeeded = nCount + 2; if ( nLimit < nNeeded ) { - nLimit += SC_MARKARRAY_DELTA; + // Assume that if it grew already beyond a certain + // threshold it will continue to grow and avoid the + // bottleneck of lots of reallocations in small steps. + // Don't use a simple "double amount" strategy though as + // that again may allocate much more than actually needed. + // The "one and a half" is just a shot into the blue sky. + if (nLimit > 4 * SC_MARKARRAY_DELTA) + nLimit += nLimit / 2; + else + nLimit += SC_MARKARRAY_DELTA; if ( nLimit < nNeeded ) nLimit = nNeeded; ScMarkEntry* pNewData = new ScMarkEntry[nLimit]; |