[Libreoffice-commits] core.git: sc/source svl/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Mar 27 11:26:55 UTC 2018


 sc/source/core/data/table1.cxx |    6 ++++--
 svl/source/items/itempool.cxx  |    9 ++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 3acc5a2383f5b0458e3caf1505fe6b8ad7dc3fb0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Mar 27 11:02:32 2018 +0200

    tdf#69977 improve creation of large charts
    
    this patch only tweaks a few things around the edges. The bulk of the
    cost is down in the chart2 module where it creates ticks and labels.
    
    Change-Id: If73a16d2f0a7511f07eff379a9b5c1b38ef96786
    Reviewed-on: https://gerrit.libreoffice.org/51931
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 5a0d97d83b60..3cb2301f2cc1 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1133,8 +1133,10 @@ void ScTable::LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol
     while ( rStartRow<rEndRow && IsEmptyLine(rStartRow, rStartCol, rEndCol) )
         ++rStartRow;
 
-    while ( rStartRow<rEndRow && IsEmptyLine(rEndRow, rStartCol, rEndCol) )
-        --rEndRow;
+    // Optimised loop for finding the bottom of the area, can be costly in large
+    // spreadsheets.
+    for (SCCOL i=rStartCol; i<=rEndCol; i++)
+        rEndRow = std::min(rEndRow, aCol[i].GetLastDataPos());
 }
 
 SCCOL ScTable::FindNextVisibleCol( SCCOL nCol, bool bRight ) const
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 3abc22b96003..07eab0ab3435 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -86,14 +86,17 @@ do { \
 
 void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser)
 {
-    pImpl->maSfxItemPoolUsers.push_back(&rNewUser);
+    // maintain sorted to reduce cost of remove
+    const auto insertIt = ::std::lower_bound(
+        pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rNewUser);
+    pImpl->maSfxItemPoolUsers.insert(insertIt, &rNewUser);
 }
 
 void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser)
 {
-    const std::vector<SfxItemPoolUser*>::iterator aFindResult = ::std::find(
+    const auto aFindResult = ::std::lower_bound(
         pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rOldUser);
-    if(aFindResult != pImpl->maSfxItemPoolUsers.end())
+    if(aFindResult != pImpl->maSfxItemPoolUsers.end() && *aFindResult == &rOldUser)
     {
         pImpl->maSfxItemPoolUsers.erase(aFindResult);
     }


More information about the Libreoffice-commits mailing list