summaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-10-25 22:48:28 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-26 20:33:45 +0200
commitf7e6153c1bcd87a7a2f2d839c49bd7615c8dca5b (patch)
treee2f457901686a27eeff74367952e92b0056c0141 /desktop
parenttdf#144513 improve perf when breaking long lines (diff)
downloadcore-f7e6153c1bcd87a7a2f2d839c49bd7615c8dca5b.tar.gz
core-f7e6153c1bcd87a7a2f2d839c49bd7615c8dca5b.zip
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.lunak@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/lib/init.hxx4
-rw-r--r--desktop/source/lib/init.cxx2
2 files changed, 4 insertions, 2 deletions
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