summaryrefslogtreecommitdiffstats
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-16 09:34:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-16 11:00:52 +0200
commit57df32e4bc12a3d67c44a1c544f7df21e1c8861e (patch)
treee59c98f2277fbaf70336e9beba9f5c82dd973acc /svl
parentDrop obsolete commented out debug output (diff)
downloadcore-57df32e4bc12a3d67c44a1c544f7df21e1c8861e.tar.gz
core-57df32e4bc12a3d67c44a1c544f7df21e1c8861e.zip
tdf#125254 Performance: A spreadsheet opens too slow, optimise listener
saves about 0.5s out of a 43s load And remove the comment in EndListeningAll, SfxBroadcaster::RemoveListener doesn't have any weird side-effects any more Change-Id: Id7c8ac1bed8ff3487cb8f977990d8fac351d7f03 Reviewed-on: https://gerrit.libreoffice.org/72396 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/notify/lstner.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 6960b12bc1d8..dcd380c86dec 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -26,15 +26,13 @@
#include <algorithm>
#include <cassert>
-#include <deque>
+#include <vector>
#include <memory>
#include <map>
-typedef std::deque<SfxBroadcaster*> SfxBroadcasterArr_Impl;
-
struct SfxListener::Impl
{
- SfxBroadcasterArr_Impl maBCs;
+ std::vector<SfxBroadcaster*> maBCs;
#ifdef DBG_UTIL
std::map<SfxBroadcaster*, std::unique_ptr<sal::BacktraceState>>
maCallStacks;
@@ -117,10 +115,10 @@ void SfxListener::StartListening(SfxBroadcaster& rBroadcaster, DuplicateHandling
void SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bRemoveAllDuplicates )
{
- SfxBroadcasterArr_Impl::iterator beginIt = mpImpl->maBCs.begin();
+ auto beginIt = mpImpl->maBCs.begin();
do
{
- SfxBroadcasterArr_Impl::iterator it = std::find( beginIt, mpImpl->maBCs.end(), &rBroadcaster );
+ auto it = std::find( beginIt, mpImpl->maBCs.end(), &rBroadcaster );
if ( it == mpImpl->maBCs.end() )
{
break;
@@ -139,13 +137,10 @@ void SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bRemoveAllDup
void SfxListener::EndListeningAll()
{
- // Attention: when optimizing this: respect side effects of RemoveListener!
- while ( !mpImpl->maBCs.empty() )
- {
- SfxBroadcaster *pBC = mpImpl->maBCs.front();
+ std::vector<SfxBroadcaster*> aBroadcasters;
+ std::swap(mpImpl->maBCs, aBroadcasters);
+ for (SfxBroadcaster *pBC : aBroadcasters)
pBC->RemoveListener(*this);
- mpImpl->maBCs.pop_front();
- }
#ifdef DBG_UTIL
mpImpl->maCallStacks.clear();
#endif