[Libreoffice-commits] core.git: basctl/source bridges/source compilerplugins/clang configmgr/source cui/source framework/source package/source registry/source sc/source sd/source sw/source ucb/source unodevtools/source unotools/source unoxml/source vcl/osx vcl/unx xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 19 11:20:52 UTC 2019


 basctl/source/basicide/documentenumeration.cxx         |    3 -
 bridges/source/cpp_uno/shared/vtablefactory.cxx        |    5 +-
 compilerplugins/clang/cstylecast.cxx                   |    6 +--
 compilerplugins/clang/memoryvar.cxx                    |    3 -
 configmgr/source/xcsparser.cxx                         |   18 +++-------
 cui/source/dialogs/FontFeaturesDialog.cxx              |    3 -
 framework/source/uielement/toolbarmanager.cxx          |   15 +++-----
 package/source/zipapi/ZipFile.cxx                      |    3 -
 registry/source/regimpl.cxx                            |    5 --
 sc/source/core/data/dpcache.cxx                        |    8 ----
 sc/source/core/data/dptabres.cxx                       |   10 +----
 sc/source/filter/excel/xestyle.cxx                     |    4 --
 sc/source/filter/xml/XMLStylesImportHelper.cxx         |   29 ++---------------
 sc/source/ui/view/dbfunc3.cxx                          |    3 -
 sd/source/ui/framework/configuration/Configuration.cxx |    3 -
 sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx    |    3 -
 sw/source/core/crsr/findattr.cxx                       |    6 +--
 sw/source/core/doc/DocumentListItemsManager.cxx        |    6 ---
 sw/source/core/layout/movedfwdfrmsbyobjpos.cxx         |    7 ----
 sw/source/core/table/swtable.cxx                       |    6 +--
 sw/source/core/unocore/unocrsrhelper.cxx               |    6 ---
 sw/source/core/unocore/unostyle.cxx                    |    3 -
 sw/source/filter/html/htmlforw.cxx                     |   10 ++---
 sw/source/filter/ww8/wrtw8sty.cxx                      |    6 +--
 sw/source/filter/ww8/ww8graf2.cxx                      |    3 -
 sw/source/filter/xml/XMLRedlineImportHelper.cxx        |   10 +----
 ucb/source/ucp/file/filtask.cxx                        |    3 -
 ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx       |    8 ----
 ucb/source/ucp/webdav/webdavcontentcaps.cxx            |    8 ----
 unodevtools/source/skeletonmaker/cppcompskeleton.cxx   |    4 --
 unodevtools/source/skeletonmaker/javacompskeleton.cxx  |    4 --
 unodevtools/source/skeletonmaker/skeletoncommon.cxx    |   20 +++--------
 unotools/source/config/fontcfg.cxx                     |    8 +---
 unoxml/source/xpath/xpathapi.cxx                       |    5 --
 vcl/osx/a11yfocustracker.cxx                           |    5 --
 vcl/unx/generic/fontmanager/fontconfig.cxx             |    3 -
 vcl/unx/generic/printer/cpdmgr.cxx                     |    9 -----
 vcl/unx/generic/printer/printerinfomanager.cxx         |    3 -
 vcl/unx/gtk/a11y/atkutil.cxx                           |    3 -
 xmloff/source/style/impastpl.cxx                       |   23 ++-----------
 xmloff/source/style/xmlnumfi.cxx                       |   12 +------
 41 files changed, 79 insertions(+), 223 deletions(-)

New commits:
commit 1a5b12aa5da2c718848d3cc5d9bce7bfcdeacf54
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Apr 18 15:13:19 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 19 13:19:31 2019 +0200

    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 at collabora.co.uk>

diff --git a/basctl/source/basicide/documentenumeration.cxx b/basctl/source/basicide/documentenumeration.cxx
index 4140bca4c906..fd1517d097f9 100644
--- a/basctl/source/basicide/documentenumeration.cxx
+++ b/basctl/source/basicide/documentenumeration.cxx
@@ -124,11 +124,10 @@ namespace basctl { namespace docs {
                         // those
                         continue;
 
-                    if ( aEncounteredModels.find( xModel ) != aEncounteredModels.end() )
+                    if ( !aEncounteredModels.insert( xModel ).second )
                         // there might be multiple frames for the same model
                         // handle it only once
                         continue;
-                    aEncounteredModels.insert( xModel );
 
                     // create a DocumentDescriptor
                     DocumentDescriptor aDescriptor;
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index a40e9e08b53d..9eb4d690204f 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -155,11 +155,12 @@ sal_Int32 VtableFactory::BaseOffset::calculate(
     typelib_InterfaceTypeDescription * type, sal_Int32 offset)
 {
     OUString name(type->aBase.pTypeName);
-    if (m_map.find(name) == m_map.end()) {
+    auto it = m_map.find(name);
+    if (it == m_map.end()) {
         for (sal_Int32 i = 0; i < type->nBaseTypes; ++i) {
             offset = calculate(type->ppBaseTypes[i], offset);
         }
-        m_map.insert({name, offset});
+        m_map.insert(it, {name, offset});
         typelib_typedescription_complete(
             reinterpret_cast< typelib_TypeDescription ** >(&type));
         offset += bridges::cpp_uno::shared::getLocalFunctions(type);
diff --git a/compilerplugins/clang/cstylecast.cxx b/compilerplugins/clang/cstylecast.cxx
index 253f19ef651c..fe3b2a19c561 100644
--- a/compilerplugins/clang/cstylecast.cxx
+++ b/compilerplugins/clang/cstylecast.cxx
@@ -603,8 +603,7 @@ bool CStyleCast::rewriteArithmeticCast(CStyleCastExpr const * expr, char const *
         secondBegin = l;
         ++secondLen;
     }
-    if (rewritten_.find(firstBegin) == rewritten_.end()) {
-        rewritten_.insert(firstBegin);
+    if (rewritten_.insert(firstBegin).second) {
         if (!replaceText(firstBegin, firstLen, functional ? "" : "static_cast<")) {
             if (isDebugMode()) {
                 report(
@@ -630,8 +629,7 @@ bool CStyleCast::rewriteArithmeticCast(CStyleCastExpr const * expr, char const *
         }
     }
     if (third.isValid()) {
-        if (rewritten_.find(third) == rewritten_.end()) {
-            rewritten_.insert(third);
+        if (rewritten_.insert(third).second) {
             if (!insertTextBefore(third, "(")) {
                 //TODO: roll back
                 if (isDebugMode()) {
diff --git a/compilerplugins/clang/memoryvar.cxx b/compilerplugins/clang/memoryvar.cxx
index d3842f4f3eb5..9cd723cf2bf8 100644
--- a/compilerplugins/clang/memoryvar.cxx
+++ b/compilerplugins/clang/memoryvar.cxx
@@ -130,8 +130,7 @@ bool MemoryVar::VisitCXXDeleteExpr(const CXXDeleteExpr *deleteExpr)
 
     SourceLocation loc = varDecl->getLocation();
 
-    if (maVarUsesSet.find(loc) == maVarUsesSet.end()) {
-        maVarUsesSet.insert(loc);
+    if (maVarUsesSet.insert(loc).second) {
         maVarDeclSourceRangeMap[loc] = varDecl->getSourceRange();
         maVarDeleteSourceRangeMap[loc] = declRefExpr->getSourceRange();
     }
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 411da6ca7915..e7bed9cc02e4 100644
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -267,24 +267,18 @@ void XcsParser::endElement(xmlreader::XmlReader const & reader) {
                 switch (state_) {
                 case STATE_TEMPLATES:
                     {
-                        NodeMap::iterator i(data_.templates.find(top.name));
-                        if (i == data_.templates.end()) {
-                            data_.templates.insert(
-                                NodeMap::value_type(top.name, top.node));
-                        } else {
-                            merge(i->second, top.node);
+                        auto itPair = data_.templates.insert({top.name, top.node});
+                        if (!itPair.second) {
+                            merge(itPair.first->second, top.node);
                         }
                     }
                     break;
                 case STATE_COMPONENT:
                     {
                         NodeMap & components = data_.getComponents();
-                        NodeMap::iterator i(components.find(top.name));
-                        if (i == components.end()) {
-                            components.insert(
-                                NodeMap::value_type(top.name, top.node));
-                        } else {
-                            merge(i->second, top.node);
+                        auto itPair = components.insert({top.name, top.node});
+                        if (!itPair.second) {
+                            merge(itPair.first->second, top.node);
                         }
                         state_ = STATE_COMPONENT_DONE;
                     }
diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx
index 27b7b18620d2..d4facba2bf7f 100644
--- a/cui/source/dialogs/FontFeaturesDialog.cxx
+++ b/cui/source/dialogs/FontFeaturesDialog.cxx
@@ -71,9 +71,8 @@ void FontFeaturesDialog::initialize()
     for (vcl::font::Feature const& rFontFeature : rFontFeatures)
     {
         sal_uInt32 nFontFeatureCode = rFontFeature.m_aID.m_aFeatureCode;
-        if (aDoneFeatures.find(nFontFeatureCode) != aDoneFeatures.end())
+        if (!aDoneFeatures.insert(nFontFeatureCode).second)
             continue;
-        aDoneFeatures.insert(nFontFeatureCode);
         rFilteredFontFeatures.push_back(rFontFeature);
     }
 
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 20d1222e552c..abaface6e133 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1042,16 +1042,14 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
                     // Fill command map. It stores all our commands and from what
                     // image manager we got our image. So we can decide if we have to use an
                     // image from a notification message.
-                    CommandToInfoMap::iterator pIter = m_aCommandMap.find( aCommandURL );
-                    if ( pIter == m_aCommandMap.end())
+                    auto pIter = m_aCommandMap.emplace( aCommandURL, aCmdInfo );
+                    if ( pIter.second )
                     {
                         aCmdInfo.nId = nId;
-                        const CommandToInfoMap::value_type aValue( aCommandURL, aCmdInfo );
-                        m_aCommandMap.insert( aValue );
                     }
                     else
                     {
-                        pIter->second.aIds.push_back( nId );
+                        pIter.first->second.aIds.push_back( nId );
                     }
 
                     if ( !bIsVisible )
@@ -1197,16 +1195,15 @@ void ToolBarManager::FillOverflowToolbar( ToolBox const * pParent )
             // Fill command map. It stores all our commands and from what
             // image manager we got our image. So we can decide if we have to use an
             // image from a notification message.
-            CommandToInfoMap::iterator pIter = m_aCommandMap.find( aCommandURL );
-            if ( pIter == m_aCommandMap.end())
+            auto pIter = m_aCommandMap.emplace( aCommandURL, aCmdInfo );
+            if ( pIter.second )
             {
                 aCmdInfo.nId = nId;
                 const CommandToInfoMap::value_type aValue( aCommandURL, aCmdInfo );
-                m_aCommandMap.insert( aValue );
             }
             else
             {
-                pIter->second.aIds.push_back( nId );
+                pIter.first->second.aIds.push_back( nId );
             }
         }
         else
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 24bcab959960..f37f38c03e62 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -1065,8 +1065,7 @@ void ZipFile::recover()
                                     aEntry.nSize = 0;
                                 }
 
-                                if ( aEntries.find( aEntry.sPath ) == aEntries.end() )
-                                    aEntries[aEntry.sPath] = aEntry;
+                                aEntries.emplace( aEntry.sPath, aEntry );
                             }
                         }
                     }
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index ea074732df12..63c937a1109a 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1109,11 +1109,8 @@ static sal_uInt32 checkTypeReaders(RegistryTypeReader const & reader1,
     }
     for (sal_uInt32 i=0 ; i < reader2.getFieldCount(); i++)
     {
-        if (nameSet.find(reader2.getFieldName(i)) == nameSet.end())
-        {
-            nameSet.insert(reader2.getFieldName(i));
+        if (nameSet.insert(reader2.getFieldName(i)).second)
             count++;
-        }
     }
     return count;
 }
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index de62e25f5d91..6222ab6ec6b4 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -120,13 +120,7 @@ private:
 
 rtl_uString* internString( ScDPCache::StringSetType& rPool, const OUString& rStr )
 {
-    ScDPCache::StringSetType::iterator it = rPool.find(rStr);
-    if (it != rPool.end())
-        // In the pool.
-        return (*it).pData;
-
-    std::pair<ScDPCache::StringSetType::iterator, bool> r = rPool.insert(rStr);
-    return r.second ? (*r.first).pData : nullptr;
+    return rPool.insert(rStr).first->pData;
 }
 
 OUString createLabelString( const ScDocument* pDoc, SCCOL nCol, const ScRefCellValue& rCell )
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index da6c053c9a8c..51c00020168d 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -3896,9 +3896,7 @@ void ScDPResultVisibilityData::addVisibleMember(const OUString& rDimName, const
         itr = r.first;
     }
     VisibleMemberType& rMem = itr->second;
-    VisibleMemberType::iterator itrMem = rMem.find(rMemberItem);
-    if (itrMem == rMem.end())
-        rMem.insert(rMemberItem);
+    rMem.insert(rMemberItem);
 }
 
 void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPFilteredCache::Criterion>& rFilters) const
@@ -3962,8 +3960,7 @@ ScDPResultMember* ScDPResultDimension::AddMember(const ScDPParentDimData &aData
     SCROW   nDataIndex = pMember->GetDataId();
     maMemberArray.emplace_back( pMember );
 
-    if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
-        maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pMember ) );
+    maMemberHash.emplace( nDataIndex, pMember );
     return pMember;
 }
 
@@ -3976,8 +3973,7 @@ ScDPResultMember* ScDPResultDimension::InsertMember(const ScDPParentDimData *pMe
         maMemberArray.emplace( maMemberArray.begin()+nInsert, pNew );
 
         SCROW   nDataIndex = pMemberData->mpMemberDesc->GetItemDataId();
-        if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
-            maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pNew ) );
+        maMemberHash.emplace( nDataIndex, pNew );
         return pNew;
     }
     return maMemberArray[ nInsert ].get();
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 1af2b2187149..9e48fd5fc7b2 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3020,10 +3020,8 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
                         aStyleName = pEntry->GetStyleName();
                     }
 
-                    if (maStyleNameToDxfId.find(aStyleName) == maStyleNameToDxfId.end())
+                    if (maStyleNameToDxfId.emplace(aStyleName, nIndex).second)
                     {
-                        maStyleNameToDxfId.insert(std::pair<OUString, sal_Int32>(aStyleName, nIndex));
-
                         SfxStyleSheetBase* pStyle = rRoot.GetDoc().GetStyleSheetPool()->Find(aStyleName);
                         if(!pStyle)
                             continue;
diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx b/sc/source/filter/xml/XMLStylesImportHelper.cxx
index ed0f8f749c57..59d7476fbd03 100644
--- a/sc/source/filter/xml/XMLStylesImportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx
@@ -116,18 +116,8 @@ void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, const boost::optio
     ScMyCurrencyStyle aStyle;
     if (pCurrency)
         aStyle.sCurrency = *pCurrency;
-    ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->find(aStyle));
-    if (aItr == pCurrencyList->end())
-    {
-        std::pair<ScMyCurrencyStylesSet::iterator, bool> aPair(pCurrencyList->insert(aStyle));
-        if (aPair.second)
-        {
-            aItr = aPair.first;
-            aItr->mpRanges->addRange(rRange);
-        }
-    }
-    else
-        aItr->mpRanges->addRange(rRange);
+    auto itPair = pCurrencyList->insert(aStyle);
+    itPair.first->mpRanges->addRange(rRange);
 }
 
 void ScMyStyleRanges::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
@@ -257,19 +247,8 @@ ScMyStylesSet::iterator ScMyStylesImportHelper::GetIterator(const boost::optiona
     {
         OSL_FAIL("here is no stylename given");
     }
-    ScMyStylesSet::iterator aItr(aCellStyles.find(aStyle));
-    if (aItr == aCellStyles.end())
-    {
-        std::pair<ScMyStylesSet::iterator, bool> aPair(aCellStyles.insert(aStyle));
-        if (aPair.second)
-            aItr = aPair.first;
-        else
-        {
-            OSL_FAIL("not possible to insert style");
-            return aCellStyles.end();
-        }
-    }
-    return aItr;
+    auto itPair = aCellStyles.insert(aStyle);
+    return itPair.first;
 }
 
 void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange)
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index f88001337b7e..40bd881535f0 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1793,9 +1793,8 @@ bool ScDBFunc::DataPilotMove( const ScRange& rSource, const ScAddress& rDest )
                 pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, rSource.aStart.Tab() ), aSourceData );
                 if ( aSourceData.Dimension == aDestData.Dimension && !aSourceData.MemberName.isEmpty() )
                 {
-                    if ( aMembersSet.find( aSourceData.MemberName ) == aMembersSet.end() )
+                    if ( aMembersSet.insert( aSourceData.MemberName ).second )
                     {
-                        aMembersSet.insert( aSourceData.MemberName );
                         aMembersVector.push_back( aSourceData.MemberName );
                     }
                     // duplicates are ignored
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.
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index c115c9b359b9..47a2a1e04266 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -990,9 +990,8 @@ bool FindAttrImpl(SwPaM & rSearchPam,
         if( !pNode->HasSwAttrSet() )
         {
             SwFormat* pTmpFormat = pNode->GetFormatColl();
-            if( aFormatArr.find( pTmpFormat ) != aFormatArr.end() )
+            if( !aFormatArr.insert( pTmpFormat ).second )
                 continue; // collection was requested earlier
-            aFormatArr.insert( pTmpFormat );
         }
 
         if( SfxItemState::SET == pNode->GetSwAttrSet().GetItemState( nWhich,
@@ -1165,9 +1164,8 @@ static bool FindAttrsImpl(SwPaM & rSearchPam,
         if (!rPropsNode.HasSwAttrSet())
         {
             SwFormat* pTmpFormat = rPropsNode.GetFormatColl();
-            if( aFormatArr.find( pTmpFormat ) != aFormatArr.end() )
+            if( !aFormatArr.insert( pTmpFormat ).second )
                 continue; // collection was requested earlier
-            aFormatArr.insert( pTmpFormat );
         }
 
         if (lcl_Search(rPropsNode, aOtherSet, bNoColls))
diff --git a/sw/source/core/doc/DocumentListItemsManager.cxx b/sw/source/core/doc/DocumentListItemsManager.cxx
index d48473003660..6fd3925d9ad6 100644
--- a/sw/source/core/doc/DocumentListItemsManager.cxx
+++ b/sw/source/core/doc/DocumentListItemsManager.cxx
@@ -45,13 +45,9 @@ void DocumentListItemsManager::addListItem( const SwNodeNum& rNodeNum )
     }
 
     const bool bAlreadyInserted(
-            mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
+            mpListItemsList->insert( &rNodeNum ).second );
     OSL_ENSURE( !bAlreadyInserted,
             "<DocumentListItemsManager::addListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
-    if ( !bAlreadyInserted )
-    {
-        mpListItemsList->insert( &rNodeNum );
-    }
 }
 
 void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum )
diff --git a/sw/source/core/layout/movedfwdfrmsbyobjpos.cxx b/sw/source/core/layout/movedfwdfrmsbyobjpos.cxx
index 0ba8984d4765..7585cd25b3e1 100644
--- a/sw/source/core/layout/movedfwdfrmsbyobjpos.cxx
+++ b/sw/source/core/layout/movedfwdfrmsbyobjpos.cxx
@@ -35,12 +35,7 @@ SwMovedFwdFramesByObjPos::~SwMovedFwdFramesByObjPos()
 void SwMovedFwdFramesByObjPos::Insert( const SwTextFrame& _rMovedFwdFrameByObjPos,
                                      const sal_uInt32 _nToPageNum )
 {
-    if ( maMovedFwdFrames.end() ==
-         maMovedFwdFrames.find(_rMovedFwdFrameByObjPos.GetTextNodeFirst()) )
-    {
-        const NodeMapEntry aEntry(_rMovedFwdFrameByObjPos.GetTextNodeFirst(), _nToPageNum);
-        maMovedFwdFrames.insert( aEntry );
-    }
+    maMovedFwdFrames.emplace(_rMovedFwdFrameByObjPos.GetTextNodeFirst(), _nToPageNum);
 }
 
 void SwMovedFwdFramesByObjPos::Remove( const SwTextFrame& _rTextFrame )
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index eee79e9e8354..337d712d95db 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2676,12 +2676,10 @@ const SwCellFrame * SwTableCellInfo::Impl::getNextTableBoxsCellFrame(const SwFra
     {
         const SwCellFrame * pCellFrame = static_cast<const SwCellFrame *>(pFrame);
         const SwTableBox * pTabBox = pCellFrame->GetTabBox();
-        TableBoxes_t::const_iterator aIt = m_HandledTableBoxes.find(pTabBox);
-
-        if (aIt == m_HandledTableBoxes.end())
+        auto aIt = m_HandledTableBoxes.insert(pTabBox);
+        if (aIt.second)
         {
             pResult = pCellFrame;
-            m_HandledTableBoxes.insert(pTabBox);
             break;
         }
     }
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 61f0f3500c74..d2c57b119166 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1373,11 +1373,7 @@ void makeTableCellRedline( SwTableBox& rTableBox,
 void SwAnyMapHelper::SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rAny )
 {
     sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
-    auto aIt = m_Map.find( nKey );
-    if (aIt != m_Map.end())
-        aIt->second = rAny;
-    else
-        m_Map.insert(std::make_pair(nKey, rAny));
+    m_Map[nKey] = rAny;
 }
 
 bool    SwAnyMapHelper::FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& pAny )
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 9c71b4f816ad..95ad63c1af03 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -3747,9 +3747,8 @@ SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAut
             if ( pItem && pItem->GetTextRuby() )
             {
                 std::pair< sal_uInt16, text::RubyAdjust > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
-                if ( aRubyMap.find( aPair ) == aRubyMap.end() )
+                if ( aRubyMap.insert( aPair ).second )
                 {
-                    aRubyMap.insert( aPair );
                     std::shared_ptr<SfxItemSet> pItemSet( new SfxItemSet( rAttrPool, svl::Items<RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY>{} ) );
                     pItemSet->Put( *pItem );
                     mAutoStyles.push_back( pItemSet );
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 5407ee03a383..3b0715581352 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -1309,13 +1309,11 @@ static void AddControl( HTMLControls& rControls,
     {
         uno::Reference< container::XIndexContainer >  xFormComps( xForm, uno::UNO_QUERY );
         std::unique_ptr<HTMLControl> pHCntrl(new HTMLControl( xFormComps, nNodeIdx ));
-        HTMLControls::const_iterator it = rControls.find( pHCntrl.get() );
-        if( it == rControls.end() )
-            rControls.insert( std::move(pHCntrl) );
-        else
+        auto itPair = rControls.insert( std::move(pHCntrl) );
+        if (!itPair.second )
         {
-            if( (*it)->xFormComps==xFormComps )
-                (*it)->nCount++;
+            if( (*itPair.first)->xFormComps==xFormComps )
+                (*itPair.first)->nCount++;
         }
     }
 }
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index f7bc5136e922..e4e24952f763 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -353,18 +353,16 @@ void MSWordStyles::BuildStyleIds()
         OString aLower(aStyleId.toAsciiLowerCase());
 
         // check for uniqueness & construct something unique if we have to
-        if (aUsed.find(aLower) == aUsed.end())
+        if (aUsed.insert(aLower).second)
         {
-            aUsed.insert(aLower);
             m_aStyleIds.push_back(aStyleId);
         }
         else
         {
             int nFree = 1;
-            while (aUsed.find(aLower + OString::number(nFree)) != aUsed.end())
+            while (!aUsed.insert(aLower + OString::number(nFree)).second)
                 ++nFree;
 
-            aUsed.insert(aLower + OString::number(nFree));
             m_aStyleIds.emplace_back(aStyleId + OString::number(nFree));
         }
     }
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 94c2036edace..f577ab60d0e1 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -259,9 +259,8 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>
     //skip duplicate graphics when fuzzing
     if (utl::ConfigManager::IsFuzzing())
     {
-        if (m_aGrafPosSet.find(nPosFc) != m_aGrafPosSet.end())
+        if (!m_aGrafPosSet.insert(nPosFc).second)
             return false;
-        m_aGrafPosSet.insert(nPosFc);
     }
 
     if (m_xWwFib->m_envr != 1) // !MAC as creator
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
 
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 941c6d36634b..1930d8cc5f07 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -2224,8 +2224,7 @@ TaskManager::load( const ContentMap::iterator& it, bool create )
                                      xS->getPropertyValue( seq[i].Name ),
                                      beans::PropertyState_DIRECT_VALUE,
                                      seq[i].Attributes );
-                if( properties.find( readProp ) == properties.end() )
-                    properties.insert( readProp );
+                properties.insert( readProp );
             }
         }
         else if( create )
diff --git a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
index e650085d6229..34daa30b9d09 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
@@ -491,17 +491,11 @@ uno::Sequence< beans::Property > Content::getProperties(
     // Add cached properties, if present and still missing.
     if (xCachedProps)
     {
-        const std::set< OUString >::const_iterator set_end
-            = aPropSet.end();
-
         const std::unique_ptr< PropertyValueMap > & xProps
             = xCachedProps->getProperties();
 
         for ( const auto& rEntry : *xProps )
-        {
-            if ( aPropSet.find( rEntry.first ) == set_end )
-                aPropSet.insert( rEntry.first );
-        }
+            aPropSet.insert( rEntry.first );
     }
 
     // std::set -> uno::Sequence
diff --git a/ucb/source/ucp/webdav/webdavcontentcaps.cxx b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
index 20a2c11ff770..d0e3558de51a 100644
--- a/ucb/source/ucp/webdav/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
@@ -440,17 +440,11 @@ uno::Sequence< beans::Property > Content::getProperties(
     // Add cached properties, if present and still missing.
     if ( xCachedProps.get() )
     {
-        const std::set< OUString >::const_iterator set_end
-            = aPropSet.end();
-
         const std::unique_ptr< PropertyValueMap > & xProps
             = xCachedProps->getProperties();
 
         for ( const auto& rEntry : *xProps )
-        {
-            if ( aPropSet.find( rEntry.first ) == set_end )
-                aPropSet.insert( rEntry.first );
-        }
+            aPropSet.insert( rEntry.first );
     }
 
     // std::set -> uno::Sequence
diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
index 097115d94879..c1fec780e9ff 100644
--- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
@@ -1101,9 +1101,7 @@ void generateCalcAddin(ProgramOptions const & options,
         // special case for the optional XLocalization interface. It should be
         // implemented always. But it is parent of the XAddIn and we need it only
         // if backwardcompatible is false.
-        if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) {
-            interfaces.insert("com.sun.star.lang.XLocalizable");
-        }
+        interfaces.insert("com.sun.star.lang.XLocalizable");
     }
 
     OUString propertyhelper = checkPropertyHelper(
diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index 741387cfe120..04cd31cb22a3 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -845,9 +845,7 @@ void generateSkeleton(ProgramOptions const & options,
             // special case for the optional XLocalization interface. It should be
             // implemented always. But it is parent of the XAddIn and we need it only
             // if backwardcompatible is false.
-            if (interfaces.find("com.sun.star.lang.XLocalizable") == interfaces.end()) {
-                interfaces.insert("com.sun.star.lang.XLocalizable");
-            }
+            interfaces.insert("com.sun.star.lang.XLocalizable");
         }
     }
 
diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
index f57afcdab7ce..37041a8be951 100644
--- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx
+++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
@@ -183,19 +183,15 @@ void checkType(rtl::Reference< TypeManager > const & manager,
         if ( name == "com.sun.star.lang.XTypeProvider" ||
              name == "com.sun.star.uno.XWeak" )
             return;
-        if (interfaceTypes.find(name) == interfaceTypes.end()) {
-            interfaceTypes.insert(name);
-        }
+        interfaceTypes.insert(name);
         break;
     case codemaker::UnoType::Sort::SingleInterfaceBasedService:
-        if (serviceTypes.find(name) == serviceTypes.end()) {
-            serviceTypes.insert(name);
+        if (serviceTypes.insert(name).second) {
             rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
                 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
                     ent.get()));
             assert(ent2.is());
-            if (interfaceTypes.find(ent2->getBase()) == interfaceTypes.end()) {
-                interfaceTypes.insert(ent2->getBase());
+            if (interfaceTypes.insert(ent2->getBase()).second) {
                 // check if constructors are specified, if yes automatically
                 // support of XInitialization. We will take care of the default
                 // constructor because in this case XInitialization is not
@@ -204,16 +200,13 @@ void checkType(rtl::Reference< TypeManager > const & manager,
                     (ent2->getConstructors().size() == 1 &&
                      !ent2->getConstructors()[0].defaultConstructor))
                 {
-                    OUString s("com.sun.star.lang.XInitialization");
-                    if (interfaceTypes.find(s) == interfaceTypes.end())
-                        interfaceTypes.insert(s);
+                    interfaceTypes.insert(OUString("com.sun.star.lang.XInitialization"));
                 }
             }
         }
         break;
     case codemaker::UnoType::Sort::AccumulationBasedService:
-        if ( serviceTypes.find(name) == serviceTypes.end() ) {
-            serviceTypes.insert(name);
+        if ( serviceTypes.insert(name).second ) {
             rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2(
                 dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
                     ent.get()));
@@ -249,8 +242,7 @@ void checkDefaultInterfaces(
     if ( services.empty() ) {
         interfaces.erase("com.sun.star.lang.XServiceInfo");
     } else {
-        if (interfaces.find("com.sun.star.lang.XServiceInfo") == interfaces.end())
-            interfaces.insert("com.sun.star.lang.XServiceInfo");
+        interfaces.insert("com.sun.star.lang.XServiceInfo");
     }
 
     if ( propertyhelper == "_" ) {
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 114e2dc37352..ecb47f59dae8 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -863,11 +863,9 @@ void FontSubstConfiguration::fillSubstVector( const css::uno::Reference< XNameAc
                     OUString aSubst( pLine->getToken( 0, ';', nIndex ) );
                     if( !aSubst.isEmpty() )
                     {
-                        UniqueSubstHash::iterator aEntry = maSubstHash.find( aSubst );
-                        if (aEntry != maSubstHash.end())
-                            aSubst = *aEntry;
-                        else
-                            maSubstHash.insert( aSubst );
+                        auto itPair = maSubstHash.insert( aSubst );
+                        if (!itPair.second)
+                            aSubst = *itPair.first;
                         rSubstVector.push_back( aSubst );
                     }
                 }
diff --git a/unoxml/source/xpath/xpathapi.cxx b/unoxml/source/xpath/xpathapi.cxx
index 9fa2e6fd2cad..415f565d3ae0 100644
--- a/unoxml/source/xpath/xpathapi.cxx
+++ b/unoxml/source/xpath/xpathapi.cxx
@@ -149,10 +149,7 @@ namespace XPath
                 const xmlChar* pPre = curDef->prefix;
                 OUString aPrefix(reinterpret_cast<char const *>(pPre), strlen(reinterpret_cast<char const *>(pPre)), RTL_TEXTENCODING_UTF8);
                 // we could already have this prefix from a child node
-                if (rNamespaces.find(aPrefix) == rNamespaces.end())
-                {
-                    rNamespaces.insert(::std::make_pair(aPrefix, aURI));
-                }
+                rNamespaces.emplace(aPrefix, aURI);
                 curDef = curDef->next;
             }
             pNode = pNode->parent;
diff --git a/vcl/osx/a11yfocustracker.cxx b/vcl/osx/a11yfocustracker.cxx
index a84b27d38d66..b62c27edfbc7 100644
--- a/vcl/osx/a11yfocustracker.cxx
+++ b/vcl/osx/a11yfocustracker.cxx
@@ -248,11 +248,8 @@ void AquaA11yFocusTracker::window_got_focus(vcl::Window *pWindow)
     }
     else
     {
-        if( m_aDocumentWindowList.find(pWindow) == m_aDocumentWindowList.end() )
-        {
-            m_aDocumentWindowList.insert(pWindow);
+        if( m_aDocumentWindowList.insert(pWindow).second )
             m_xDocumentFocusListener->attachRecursive(xAccessible, xContext, xStateSet);
-        }
     }
 }
 
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 2cb1aee919d9..e13eb0a82716 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -1041,9 +1041,8 @@ void PrintFontManager::Substitute(FontSelectPattern &rPattern, OUString& rMissin
                         {
                             LanguageTag aOurTag(getExemplarLangTagForCodePoint(pRemainingCodes[i]));
                             OString sTag = OUStringToOString(aOurTag.getBcp47(), RTL_TEXTENCODING_UTF8);
-                            if (m_aPreviousLangSupportRequests.find(sTag) != m_aPreviousLangSupportRequests.end())
+                            if (!m_aPreviousLangSupportRequests.insert(sTag).second)
                                 continue;
-                            m_aPreviousLangSupportRequests.insert(sTag);
                             sTag = mapToFontConfigLangTag(aOurTag);
                             if (!sTag.isEmpty() && m_aPreviousLangSupportRequests.find(sTag) == m_aPreviousLangSupportRequests.end())
                             {
diff --git a/vcl/unx/generic/printer/cpdmgr.cxx b/vcl/unx/generic/printer/cpdmgr.cxx
index 195708d1953b..fe3b44918d16 100644
--- a/vcl/unx/generic/printer/cpdmgr.cxx
+++ b/vcl/unx/generic/printer/cpdmgr.cxx
@@ -193,14 +193,7 @@ std::vector<std::pair<std::string, gchar*>> const & CPDManager::getTempBackends(
 }
 
 void CPDManager::addNewPrinter(const OUString& aPrinterName, const OUString& aUniqueName, CPDPrinter *pDest) {
-    std::pair<OUString, CPDPrinter *> newPrinter (aUniqueName, pDest);
-    std::unordered_map<OUString, CPDPrinter *>::iterator it = m_aCPDDestMap.find( aUniqueName );
-    if (it == m_aCPDDestMap.end()) {
-        m_aCPDDestMap.insert(newPrinter);
-    } else {
-        m_aCPDDestMap.erase(it);
-        m_aCPDDestMap.insert(newPrinter);
-    }
+    m_aCPDDestMap[aUniqueName] = pDest;
     bool bSetToGlobalDefaults = m_aPrinters.find( aUniqueName ) == m_aPrinters.end();
     Printer aPrinter = m_aPrinters[ aUniqueName ];
     if( bSetToGlobalDefaults )
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index 0d61ae9ef67d..28ba5eee2e7b 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -818,12 +818,11 @@ static void standardSysQueueTokenHandler(
                 // get the queue name between fore and aft tokens
                 OUString aSysQueue( OStringToOUString( line.copy( nPos, nAftPos - nPos ), aEncoding ) );
                 // do not insert duplicates (e.g. lpstat tends to produce such lines)
-                if( aUniqueSet.find( aSysQueue ) == aUniqueSet.end() )
+                if( aUniqueSet.insert( aSysQueue ).second )
                 {
                     o_rQueues.emplace_back( );
                     o_rQueues.back().m_aQueue = aSysQueue;
                     o_rQueues.back().m_aLocation = aSysQueue;
-                    aUniqueSet.insert( aSysQueue );
                 }
             }
         }
diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx
index 92905f6ec64b..e76cf990228a 100644
--- a/vcl/unx/gtk/a11y/atkutil.cxx
+++ b/vcl/unx/gtk/a11y/atkutil.cxx
@@ -576,9 +576,8 @@ static void handle_get_focus(::VclWindowEvent const * pEvent)
     }
     else
     {
-        if( g_aWindowList.list.find(pWindow) == g_aWindowList.list.end() )
+        if( g_aWindowList.list.insert(pWindow).second )
         {
-            g_aWindowList.list.insert(pWindow);
             try
             {
                 rDocumentFocusListener.attachRecursive(xAccessible, xContext, xStateSet);
diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx
index 191f178635ea..1b574adc8b97 100644
--- a/xmloff/source/style/impastpl.cxx
+++ b/xmloff/source/style/impastpl.cxx
@@ -511,16 +511,9 @@ bool SvXMLAutoStylePoolP_Impl::Add(
     XMLAutoStyleFamily &rFamily = **iter;
 
     std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
-    auto it2 = rFamily.m_ParentSet.find(pTmp);
-    if (it2 == rFamily.m_ParentSet.end())
-    {
-        std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
-            rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
+    auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
                         rParentName));
-        it2 = r.first;
-    }
-
-    XMLAutoStylePoolParent& rParent = **it2;
+    XMLAutoStylePoolParent& rParent = **itPair.first;
 
     bool bRet = false;
     if (rParent.Add(rFamily, rProperties, rName, bDontSeek))
@@ -544,17 +537,9 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed(
 
     XMLAutoStyleFamily &rFamily = **iter;
 
-    std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
-    auto it2 = rFamily.m_ParentSet.find(pTmp);
-    if (it2 == rFamily.m_ParentSet.end())
-    {
-        std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
-            rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
+    auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
                         rParentName));
-        it2 = r.first;
-    }
-
-    XMLAutoStylePoolParent& rParent = **it2;
+    XMLAutoStylePoolParent& rParent = **itPair.first;
 
     bool bRet = false;
     if (rParent.AddNamed(rFamily, rProperties, rName))
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 1a7b81c6f311..100ada1d3ec7 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -1083,16 +1083,10 @@ void SvXMLNumFmtElementContext::AddEmbeddedElement( sal_Int32 nFormatPos, const
     if (rContent.isEmpty())
         return;
 
-    auto const iter(aNumInfo.m_EmbeddedElements.find(nFormatPos));
-    if (iter == aNumInfo.m_EmbeddedElements.end())
-    {
-        aNumInfo.m_EmbeddedElements.insert(std::make_pair(nFormatPos, rContent));
-    }
-    else
-    {
+    auto iterPair = aNumInfo.m_EmbeddedElements.emplace(nFormatPos, rContent);
+    if (!iterPair.second)
         // there's already an element at this position - append text to existing element
-        iter->second += rContent;
-    }
+        iterPair.first->second += rContent;
 }
 
 void SvXMLNumFmtElementContext::EndElement()


More information about the Libreoffice-commits mailing list