summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-27 11:02:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-27 13:26:30 +0200
commit3acc5a2383f5b0458e3caf1505fe6b8ad7dc3fb0 (patch)
tree789b5622e9775eddcfb1cc4a1f683fd162779aca
parentc49b42fcc8687fafdbb9db41a58ff4f8208d0896 (diff)
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@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/core/data/table1.cxx6
-rw-r--r--svl/source/items/itempool.cxx9
2 files changed, 10 insertions, 5 deletions
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);
}