oox/source/export/drawingml.cxx                      |    5 +++--
 oox/source/export/vmlexport.cxx                      |    5 +++--
 oox/source/ole/oleobjecthelper.cxx                   |    5 +++--
 sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx |    5 +++--
 shell/source/win32/ooofilereader/simpletag.cxx       |    7 ++++---
 sw/source/core/doc/dbgoutsw.cxx                      |    6 ++++--
 sw/source/filter/ww8/docxattributeoutput.cxx         |    5 +++--
 sw/source/uibase/envelp/labelcfg.cxx                 |    4 ++--
 sw/source/uibase/utlui/content.cxx                   |    5 +++--
 toolkit/source/controls/unocontrolmodel.cxx          |   15 +++++++++------
 10 files changed, 37 insertions(+), 25 deletions(-)

New commits:
commit d0e848dab096160b16c4778ba25a40d1e5ff82af
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Nov 15 10:48:27 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Nov 15 12:04:31 2023 +0100

    avoid double map lookup
    
    Change-Id: I02018eaaf220c7835756eba6215425bac9cbc6f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159432
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index ebe1df3a72d8..4bce89943ba3 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4320,8 +4320,9 @@ void DrawingML::WritePresetShape( const OString& pShape, 
MSO_SPT eShapeType, boo
     static std::map< OString, std::vector<OString> > aAdjMap = 
lcl_getAdjNames();
     // If there are predefined adj names for this shape type, look them up now.
     std::vector<OString> aAdjustments;
-    if (aAdjMap.find(pShape) != aAdjMap.end())
-        aAdjustments = aAdjMap[pShape];
+    auto it = aAdjMap.find(pShape);
+    if (it != aAdjMap.end())
+        aAdjustments = it->second;
 
     mpFS->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
     mpFS->startElementNS(XML_a, XML_avLst);
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 2ed2903bfe27..cfaa815aa964 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1236,8 +1236,9 @@ static OUString lcl_getAnchorIdFromGrabBag(const 
SdrObject* pSdrObject)
     if (xShape->getPropertySetInfo()->hasPropertyByName("InteropGrabBag"))
     {
         comphelper::SequenceAsHashMap 
aInteropGrabBag(xShape->getPropertyValue("InteropGrabBag"));
-        if (aInteropGrabBag.find("AnchorId") != aInteropGrabBag.end())
-            aInteropGrabBag["AnchorId"] >>= aResult;
+        auto it = aInteropGrabBag.find("AnchorId");
+        if (it != aInteropGrabBag.end())
+            it->second >>= aResult;
     }
 
     return aResult;
diff --git a/oox/source/ole/oleobjecthelper.cxx 
b/oox/source/ole/oleobjecthelper.cxx
index 1816773db82d..f99e4a897ec0 100644
--- a/oox/source/ole/oleobjecthelper.cxx
+++ b/oox/source/ole/oleobjecthelper.cxx
@@ -100,8 +100,9 @@ void SaveInteropProperties(uno::Reference<frame::XModel> 
const& xModel,
 
     // get EmbeddedObjects property inside grab bag
     comphelper::SequenceAsHashMap objectsList;
-    if (aGrabBag.find(sEmbeddingsPropName) != aGrabBag.end())
-        objectsList << aGrabBag[sEmbeddingsPropName];
+    auto grabIt = aGrabBag.find(sEmbeddingsPropName);
+    if (grabIt != aGrabBag.end())
+        objectsList << grabIt->second;
 
     uno::Sequence< beans::PropertyValue > aGrabBagAttribute{ 
comphelper::makePropertyValue("ProgID",
                                                                                
            rProgId) };
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx 
b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index fa57dd1a4fe7..7aaa7237ccac 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -1170,8 +1170,9 @@ uno::Reference<XAccessible > SAL_CALL
                 throw lang::IndexOutOfBoundsException();
             }
             ScMyAddress addr = 
CalcScAddressFromRangeList(mpMarkedRanges.get(),nSelectedChildIndex);
-            if( m_mapSelectionSend.find(addr) != m_mapSelectionSend.end() )
-                xAccessible = m_mapSelectionSend[addr];
+            auto it = m_mapSelectionSend.find(addr);
+            if( it != m_mapSelectionSend.end() )
+                xAccessible = it->second;
             else
                 xAccessible = getAccessibleCellAt(addr.Row(), addr.Col());
         }
diff --git a/shell/source/win32/ooofilereader/simpletag.cxx 
b/shell/source/win32/ooofilereader/simpletag.cxx
index 82b85aec5ce3..d4ceab77fe10 100644
--- a/shell/source/win32/ooofilereader/simpletag.cxx
+++ b/shell/source/win32/ooofilereader/simpletag.cxx
@@ -48,10 +48,11 @@ std::wstring CSimpleTag::getTagContent( )
 
 ::std::wstring CSimpleTag::getTagAttribute( ::std::wstring const & attrname )
 {
-    if  ( m_SimpleAttributes.find(attrname) != m_SimpleAttributes.end())
-        return m_SimpleAttributes[attrname];
+    auto it = m_SimpleAttributes.find(attrname);
+    if  ( it != m_SimpleAttributes.end())
+        return it->second;
     else
-        return ( ::std::wstring( EMPTY_STRING ) );
+        return ::std::wstring( EMPTY_STRING );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index a6edc6f0cc12..1de4b7153543 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -224,8 +224,10 @@ static OUString lcl_dbg_out(const SfxPoolItem & rItem)
 {
     OUString aStr("[ ");
 
-    if (GetItemWhichMap().find(rItem.Which()) != GetItemWhichMap().end())
-        aStr += GetItemWhichMap()[rItem.Which()];
+    auto & rWhichMap = GetItemWhichMap();
+    auto it = rWhichMap.find(rItem.Which());
+    if ( it != rWhichMap.end())
+        aStr += it->second;
     else
         aStr += OUString::number(rItem.Which());
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 41bed36093cd..ee514c8eea29 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4413,8 +4413,9 @@ static void impl_borders( FSHelperPtr const & pSerializer,
     {
         const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
         const table::BorderLine2 *aStyleProps = nullptr;
-        if( rTableStyleConf.find( *pBrd ) != rTableStyleConf.end() )
-            aStyleProps = &rTableStyleConf[ *pBrd ];
+        auto it = rTableStyleConf.find( *pBrd );
+        if( it != rTableStyleConf.end() )
+            aStyleProps = &(it->second);
 
         if (!tagWritten && rOptions.bWriteTag)
         {
diff --git a/sw/source/uibase/envelp/labelcfg.cxx 
b/sw/source/uibase/envelp/labelcfg.cxx
index 8d98c7a9f1eb..f974a3e799db 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -251,8 +251,8 @@ void    SwLabelConfig::FillLabels(const OUString& 
rManufacturer, SwLabRecs& rLab
 
 bool    SwLabelConfig::HasLabel(const OUString& rManufacturer, const OUString& 
rType)
 {
-    return ( ( m_aLabels.find(rManufacturer) != m_aLabels.end() ) &&
-             ( m_aLabels[rManufacturer].find(rType) != 
m_aLabels[rManufacturer].end() ) );
+    auto it = m_aLabels.find(rManufacturer);
+    return ( it != m_aLabels.end() ) && ( it->second.find(rType) != 
it->second.end() );
 }
 
 // label is always saved as a custom label
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 4c126fb6193d..5dc3d87aaf14 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1135,8 +1135,9 @@ 
SwContentTree::SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNaviga
     if (SwView* pView = GetActiveView(); pView && pView->GetDocShell())
     {
         OUString sDocTitle = pView->GetDocShell()->GetTitle();
-        if (lcl_DocOutLineExpandStateMap.find(sDocTitle) != 
lcl_DocOutLineExpandStateMap.end())
-            mOutLineNodeMap = lcl_DocOutLineExpandStateMap[sDocTitle];
+        auto it = lcl_DocOutLineExpandStateMap.find(sDocTitle);
+        if (it != lcl_DocOutLineExpandStateMap.end())
+            mOutLineNodeMap = it->second;
         if (comphelper::LibreOfficeKit::isActive()) {
             if (pView->m_nNaviExpandedStatus < 0)
                 m_nActiveBlock = 1;
diff --git a/toolkit/source/controls/unocontrolmodel.cxx 
b/toolkit/source/controls/unocontrolmodel.cxx
index 76bee95cf2ac..de573b11e1a5 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -900,8 +900,9 @@ void UnoControlModel::read( const css::uno::Reference< 
css::io::XObjectInputStre
                         if ( !pFD )
                         {
                             pFD.reset(new css::awt::FontDescriptor);
-                            if ( maData.find( BASEPROPERTY_FONTDESCRIPTOR ) != 
maData.end() ) // due to defaults...
-                                maData[ BASEPROPERTY_FONTDESCRIPTOR ] >>= *pFD;
+                            auto it = maData.find( BASEPROPERTY_FONTDESCRIPTOR 
);
+                            if ( it != maData.end() ) // due to defaults...
+                                it->second >>= *pFD;
                         }
                         pFD->Name = InStream->readUTF();
                         pFD->StyleName = InStream->readUTF();
@@ -917,8 +918,9 @@ void UnoControlModel::read( const css::uno::Reference< 
css::io::XObjectInputStre
                         if ( !pFD )
                         {
                             pFD.reset(new css::awt::FontDescriptor);
-                            if ( maData.find(BASEPROPERTY_FONTDESCRIPTOR) != 
maData.end() ) // due to defaults...
-                                maData[BASEPROPERTY_FONTDESCRIPTOR] >>= *pFD;
+                            auto it = maData.find(BASEPROPERTY_FONTDESCRIPTOR);
+                            if ( it != maData.end() ) // due to defaults...
+                                it->second >>= *pFD;
                         }
                         pFD->Width = 
static_cast<sal_Int16>(InStream->readLong());
                         pFD->Height = 
static_cast<sal_Int16>(InStream->readLong());
@@ -934,8 +936,9 @@ void UnoControlModel::read( const css::uno::Reference< 
css::io::XObjectInputStre
                         if ( !pFD )
                         {
                             pFD.reset(new css::awt::FontDescriptor);
-                            if ( maData.find(BASEPROPERTY_FONTDESCRIPTOR) != 
maData.end() ) // due to defaults...
-                                maData[BASEPROPERTY_FONTDESCRIPTOR] >>= *pFD;
+                            auto it = maData.find(BASEPROPERTY_FONTDESCRIPTOR);
+                            if ( it != maData.end() ) // due to defaults...
+                                it->second >>= *pFD;
                         }
                         pFD->Weight = 
vcl::unohelper::ConvertFontWeight(static_cast<FontWeight>(InStream->readShort()));
                         pFD->Slant =  
static_cast<css::awt::FontSlant>(InStream->readShort());

Reply via email to