summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 13:01:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 21:39:58 +0200
commitcc4325f84a0ba35d8bbb564512bce0c6b8aab408 (patch)
tree3176a56fd68c3f9d689a8244a4d118a7484c8a66 /configmgr
parent3c140247d1477d565680731434df7b82d01f4775 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/config_map.hxx5
-rw-r--r--configmgr/source/nodemap.cxx7
-rw-r--r--configmgr/source/nodemap.hxx5
3 files changed, 9 insertions, 8 deletions
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(); }
};
}