summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml/XMLRedlineImportHelper.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-18 15:13:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-19 13:19:31 +0200
commit1a5b12aa5da2c718848d3cc5d9bce7bfcdeacf54 (patch)
tree25044edc2afb99073ba6bef8d181dadbb6a53467 /sw/source/filter/xml/XMLRedlineImportHelper.cxx
parenteaaaad0e21edb27edaa865eee03696f007cd8010 (diff)
optimise find/insert pattern
if we're doing a find/insert on a set or a map, it is better to just do a conditional insert/emplace operation than triggering two lookups. Change-Id: I80da5097f5a89fe30fa348ce5b6e747c34287a8d Reviewed-on: https://gerrit.libreoffice.org/70937 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/xml/XMLRedlineImportHelper.cxx')
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.cxx10
1 files changed, 3 insertions, 7 deletions
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index d78e7e6b4849..ee3563c497a1 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -418,12 +418,8 @@ void XMLRedlineImportHelper::Add(
pInfo->bMergeLastParagraph = bMergeLastPara;
// ad 3)
- if (aRedlineMap.end() == aRedlineMap.find(rId))
- {
- // 3a) insert into map
- aRedlineMap[rId] = pInfo;
- }
- else
+ auto itPair = aRedlineMap.emplace(rId, pInfo);
+ if (!itPair.second)
{
// 3b) we already have a redline with this name: hierarchical redlines
// insert pInfo as last element in the chain.
@@ -431,7 +427,7 @@ void XMLRedlineImportHelper::Add(
// find last element
RedlineInfo* pInfoChain;
- for( pInfoChain = aRedlineMap[rId];
+ for( pInfoChain = itPair.first->second;
nullptr != pInfoChain->pNextRedline;
pInfoChain = pInfoChain->pNextRedline) ; // empty loop