desktop/inc/lib/init.hxx    |    4 +++-
 desktop/source/lib/init.cxx |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

New commits:
commit f7e6153c1bcd87a7a2f2d839c49bd7615c8dca5b
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Mon Oct 25 22:48:28 2021 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Oct 26 20:33:45 2021 +0200

    use boost flat_map for faster map
    
    setUpdatedTypePerViewId() gets called so often that even unordered_map
    lookup and allocations show up in profiling. It seems that flat_map
    can do better.
    
    Change-Id: Id2e4f0c40d6973b51e557f84a08bf12feb58b3ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124210
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 01620a4f02ac..337c0f23340c 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -17,6 +17,7 @@
 
 #include <boost/property_tree/ptree.hpp>
 #include <boost/variant.hpp>
+#include <boost/container/flat_map.hpp>
 
 #include <osl/thread.h>
 #include <rtl/ref.hxx>
@@ -199,7 +200,8 @@ namespace desktop {
             bool set; // value is if set
             int sourceViewId;
         };
-        std::unordered_map<int, std::vector<PerViewIdData>> 
m_updatedTypesPerViewId; // key is view, index is type
+        // Flat_map is used in preference to unordered_map because the map is 
accessed very often.
+        boost::container::flat_map<int, std::vector<PerViewIdData>> 
m_updatedTypesPerViewId; // key is view, index is type
 
         LibreOfficeKitDocument* m_pDocument;
         int m_viewId = -1; // view id of the associated SfxViewShell
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 30bfd4594754..8543bfd49513 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2138,7 +2138,7 @@ void CallbackFlushHandler::enqueueUpdatedTypes()
     // First move data to local structures, so that callbacks don't possibly 
modify it.
     std::vector<bool> updatedTypes;
     std::swap(updatedTypes, m_updatedTypes);
-    std::unordered_map<int, std::vector<PerViewIdData>> updatedTypesPerViewId;
+    boost::container::flat_map<int, std::vector<PerViewIdData>> 
updatedTypesPerViewId;
     std::swap(updatedTypesPerViewId, m_updatedTypesPerViewId);
 
     // Some types must always precede other types, for example

Reply via email to