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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu May 16 09:01:29 UTC 2019


 svl/source/notify/lstner.cxx |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

New commits:
commit 57df32e4bc12a3d67c44a1c544f7df21e1c8861e
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 16 09:34:16 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu May 16 11:00:52 2019 +0200

    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 at collabora.co.uk>

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


More information about the Libreoffice-commits mailing list