diff options
author | Eike Rathke <erack@redhat.com> | 2017-06-07 00:49:47 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2017-06-07 06:10:24 +0200 |
commit | 2f25f408228528395f722f9332020ba9b13ed334 (patch) | |
tree | f452b97bf494d441160697102e289c826d111071 | |
parent | 5c4fadb90028f000e6c8269c8d37545b2776f5d8 (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
(cherry picked from commit 59c9d0653cc42560af48269bb8dee2c2b0b20f68)
Reviewed-on: https://gerrit.libreoffice.org/38477
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
-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]; |