diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-18 15:13:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-19 13:19:31 +0200 |
commit | 1a5b12aa5da2c718848d3cc5d9bce7bfcdeacf54 (patch) | |
tree | 25044edc2afb99073ba6bef8d181dadbb6a53467 /sd | |
parent | eaaaad0e21edb27edaa865eee03696f007cd8010 (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 'sd')
-rw-r--r-- | sd/source/ui/framework/configuration/Configuration.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx index c2088a207092..c2438477c01a 100644 --- a/sd/source/ui/framework/configuration/Configuration.cxx +++ b/sd/source/ui/framework/configuration/Configuration.cxx @@ -100,11 +100,10 @@ void SAL_CALL Configuration::addResource (const Reference<XResourceId>& rxResour if ( ! rxResourceId.is() || rxResourceId->getResourceURL().isEmpty()) throw css::lang::IllegalArgumentException(); - if (mpResourceContainer->find(rxResourceId) == mpResourceContainer->end()) + if (mpResourceContainer->insert(rxResourceId).second) { SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": Configuration::addResource() " << FrameworkHelper::ResourceIdToString(rxResourceId)); - mpResourceContainer->insert(rxResourceId); PostEvent(rxResourceId, true); } } diff --git a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx index 0307268da2b9..a7a8880bcbf6 100644 --- a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx @@ -127,9 +127,8 @@ void CurrentMasterPagesSelector::Fill (ItemList& rItemList) // Use the name of the master page to avoid duplicate entries. OUString sName (pMasterPage->GetName()); - if (aMasterPageNames.find(sName)!=aMasterPageNames.end()) + if (!aMasterPageNames.insert(sName).second) continue; - aMasterPageNames.insert (sName); // Look up the master page in the container and, when it is not yet // in it, insert it. |