summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-04-26 08:41:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-28 08:23:04 +0200
commita33922e38b87db5b009986324c6543e90f18a752 (patch)
tree9c0d80bd1c55677efa6e3241fd3d6107c6c58c0c /configmgr
parent2eb3922750b385dcadfd124d7baf686cec40eb5e (diff)
optimise find/insert calls to maps
Instead of doing two lookups, we can just call insert and then update the mapped-to value if the insert actually succeeded. Change-Id: I3df3b98f0debe6bf74c739dd5850e7714d9c2789 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151030 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/valueparser.cxx7
1 files changed, 3 insertions, 4 deletions
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 82778e6c823b..17174368d59b 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -352,12 +352,11 @@ bool ValueParser::endElement() {
case Node::KIND_LOCALIZED_PROPERTY:
{
NodeMap & members = node_->getMembers();
- NodeMap::iterator i(members.find(localizedName_));
+ auto [i, bInserted] = members.insert(NodeMap::value_type(localizedName_, nullptr));
LocalizedValueNode *pLVNode;
- if (i == members.end()) {
+ if (bInserted) {
pLVNode = new LocalizedValueNode(layer_);
- members.insert(
- NodeMap::value_type(localizedName_, pLVNode ));
+ i->second = pLVNode;
} else {
pLVNode = static_cast< LocalizedValueNode * >(i->second.get());
}