[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/source

Eike Rathke erack at redhat.com
Wed Jun 7 04:10:44 UTC 2017


 sc/source/core/data/markarr.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 2f25f408228528395f722f9332020ba9b13ed334
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Jun 7 00:49:47 2017 +0200

    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 at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

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];


More information about the Libreoffice-commits mailing list