configmgr/source/config_map.hxx |    5 +++--
 configmgr/source/nodemap.cxx    |    7 +++----
 configmgr/source/nodemap.hxx    |    5 +++--
 3 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit cc4325f84a0ba35d8bbb564512bce0c6b8aab408
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun May 15 13:01:22 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun May 15 21:39:58 2022 +0200

    use boost::flat_map in config_map
    
    reduces time spent allocating
    
    Change-Id: Idd571db62d28be7e48672f76d741174a7ab40959
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134346
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/configmgr/source/config_map.hxx b/configmgr/source/config_map.hxx
index 5d2990d5a0d8..f968165736d1 100644
--- a/configmgr/source/config_map.hxx
+++ b/configmgr/source/config_map.hxx
@@ -9,7 +9,7 @@
 #ifndef CONFIG_MAP_HXX
 #define CONFIG_MAP_HXX
 
-#include <map>
+#include <boost/container/flat_map.hpp>
 #include <rtl/ustring.hxx>
 
 // The realisation here is that while a map is a reasonably compact
@@ -28,7 +28,8 @@ struct LengthContentsCompare
     }
 };
 
-template <class T> struct config_map : public std::map<OUString, T, 
LengthContentsCompare>
+template <class T>
+struct config_map : public boost::container::flat_map<OUString, T, 
LengthContentsCompare>
 {
 };
 
diff --git a/configmgr/source/nodemap.cxx b/configmgr/source/nodemap.cxx
index e21578b2880b..0b524846bfcd 100644
--- a/configmgr/source/nodemap.cxx
+++ b/configmgr/source/nodemap.cxx
@@ -42,10 +42,9 @@ void NodeMap::cloneInto(NodeMap* target) const
 
 rtl::Reference<Node> NodeMap::findNode(int layer, OUString const& name) const
 {
-    const_iterator i;
-    if (maCache == end() || maCache->first != name)
-        maCache = const_cast<NodeMap*>(this)->maImpl.find(name);
-    i = maCache;
+    if (!moCache || (*moCache)->first != name)
+        moCache = const_cast<NodeMap*>(this)->maImpl.find(name);
+    const_iterator i = *moCache;
     return i == end() || i->second->getLayer() > layer ? 
rtl::Reference<Node>() : i->second;
 }
 }
diff --git a/configmgr/source/nodemap.hxx b/configmgr/source/nodemap.hxx
index 19447c7f77f7..b03a6503bb22 100644
--- a/configmgr/source/nodemap.hxx
+++ b/configmgr/source/nodemap.hxx
@@ -23,6 +23,7 @@
 #include "config_map.hxx"
 #include <rtl/ref.hxx>
 #include "node.hxx"
+#include <optional>
 
 namespace configmgr {
 
@@ -59,8 +60,8 @@ class NodeMap
 
 private:
     // We get a large number of repeated identical lookups.
-    mutable const_iterator maCache;
-    void clearCache() { maCache = maImpl.end(); }
+    mutable std::optional<const_iterator> moCache;
+    void clearCache() { moCache.reset(); }
 };
 
 }

Reply via email to