From 3acc5a2383f5b0458e3caf1505fe6b8ad7dc3fb0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 27 Mar 2018 11:02:32 +0200 Subject: 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 Reviewed-by: Noel Grandin --- svl/source/items/itempool.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'svl') 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::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); } -- cgit