diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-11 11:36:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-11 13:51:29 +0200 |
commit | db17a874af37350b3270932175854ee674447bc1 (patch) | |
tree | fecc983fb75d3a4072cc7bd344fc824d548deb0d /sw | |
parent | dd8a400bbbb1b8d5592a870f2036a4df3d005a7d (diff) |
convert std::map::insert to std::map::emplace II
Change-Id: Ief8bd59c903625ba65b75114b7b52c3b7ecbd331
Reviewed-on: https://gerrit.libreoffice.org/41019
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/access/accfrmobjmap.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/access/accfrmobjmap.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/access/acchypertextdata.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/access/accmap.cxx | 39 | ||||
-rw-r--r-- | sw/source/core/access/accpara.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 2 |
7 files changed, 26 insertions, 33 deletions
diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx index 43da30d7dbad..18bdd32421f3 100644 --- a/sw/source/core/access/accfrmobjmap.cxx +++ b/sw/source/core/access/accfrmobjmap.cxx @@ -126,8 +126,7 @@ std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert( const SwAccessibleChild& rLower ) { SwAccessibleChildMapKey aKey( eLayerId, nPos ); - value_type aEntry( aKey, rLower ); - return insert( aEntry ); + return emplace( aKey, rLower ); } std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert( @@ -142,8 +141,7 @@ std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert( ? SwAccessibleChildMapKey::CONTROLS : SwAccessibleChildMapKey::HEAVEN ); SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() ); - value_type aEntry( aKey, rLower ); - return insert( aEntry ); + return emplace( aKey, rLower ); } bool SwAccessibleChildMap::IsSortingRequired( const SwFrame& rFrame ) diff --git a/sw/source/core/access/accfrmobjmap.hxx b/sw/source/core/access/accfrmobjmap.hxx index 819c3313ce16..2376bde34175 100644 --- a/sw/source/core/access/accfrmobjmap.hxx +++ b/sw/source/core/access/accfrmobjmap.hxx @@ -117,7 +117,8 @@ public: const_reverse_iterator crbegin() const { return maMap.crbegin(); } const_reverse_iterator crend() const { return maMap.crend(); } - std::pair<iterator,bool> insert(const value_type& value) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } }; #endif diff --git a/sw/source/core/access/acchypertextdata.hxx b/sw/source/core/access/acchypertextdata.hxx index ea1d349371ee..7a0c5e775c8c 100644 --- a/sw/source/core/access/acchypertextdata.hxx +++ b/sw/source/core/access/acchypertextdata.hxx @@ -45,7 +45,8 @@ public: iterator begin() { return maMap.begin(); } iterator end() { return maMap.end(); } iterator find(const key_type& key) { return maMap.find(key); } - std::pair<iterator,bool> insert(const value_type& value ) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } }; #endif diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index cf74ec6d9222..3ca56245b1b0 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -113,7 +113,8 @@ public: bool empty() const { return maMap.empty(); } void clear() { maMap.clear(); } iterator find(const key_type& key) { return maMap.find(key); } - std::pair<iterator,bool> insert(const value_type& value ) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } iterator erase(const_iterator const & pos) { return maMap.erase(pos); } }; @@ -257,7 +258,8 @@ public: const_iterator cend() const { return maMap.cend(); } bool empty() const { return maMap.empty(); } iterator find(const key_type& key) { return maMap.find(key); } - std::pair<iterator,bool> insert(const value_type& value ) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } iterator erase(const_iterator const & pos) { return maMap.erase(pos); } }; @@ -588,7 +590,8 @@ private: public: iterator end() { return maMap.end(); } iterator find(const key_type& key) { return maMap.find(key); } - std::pair<iterator,bool> insert(const value_type& value ) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } iterator erase(const_iterator const & pos) { return maMap.erase(pos); } }; @@ -628,7 +631,8 @@ public: iterator begin() { return maMap.begin(); } iterator end() { return maMap.end(); } iterator find(const key_type& key) { return maMap.find(key); } - std::pair<iterator,bool> insert(const value_type& value ) { return maMap.insert(value); } + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); } iterator erase(const_iterator const & pos) { return maMap.erase(pos); } }; @@ -1042,9 +1046,8 @@ void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent ) } else if( SwAccessibleEvent_Impl::DISPOSE != rEvent.GetType() ) { - SwAccessibleEventMap_Impl::value_type aEntry( rEvent.GetFrameOrObj(), + mpEventMap->emplace( rEvent.GetFrameOrObj(), mpEvents->insert( mpEvents->end(), rEvent ) ); - mpEventMap->insert( aEntry ); } } } @@ -1349,7 +1352,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() vecAdd.push_back(static_cast< SwAccessibleContext * >(xAcc.get())); } - mapTemp.insert( SwAccessibleContextMap_Impl::value_type( pFrame, xAcc ) ); + mapTemp.emplace( pFrame, xAcc ); } } ++nStartIndex; @@ -1379,7 +1382,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() SwAccessibleContextMap_Impl::iterator aIter = mapTemp.begin(); while( aIter != mapTemp.end() ) { - mpSeletedFrameMap->insert( SwAccessibleContextMap_Impl::value_type( (*aIter).first, (*aIter).second ) ); + mpSeletedFrameMap->emplace( (*aIter).first, (*aIter).second ); ++aIter; } mapTemp.clear(); @@ -1760,8 +1763,7 @@ uno::Reference< XAccessible > SwAccessibleMap::GetDocumentView_( } else { - SwAccessibleContextMap_Impl::value_type aEntry( pRootFrame, xAcc ); - mpFrameMap->insert( aEntry ); + mpFrameMap->emplace( pRootFrame, xAcc ); } } @@ -1889,8 +1891,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrame *pFrame, } else { - SwAccessibleContextMap_Impl::value_type aEntry( pFrame, xAcc ); - mpFrameMap->insert( aEntry ); + mpFrameMap->emplace( pFrame, xAcc ); } if( pAcc->HasCursor() && @@ -1986,9 +1987,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( } else { - SwAccessibleShapeMap_Impl::value_type aEntry( pObj, - xAcc ); - mpShapeMap->insert( aEntry ); + mpShapeMap->emplace( pObj, xAcc ); } // TODO: focus!!! AddGroupContext(pObj, xAcc); @@ -2016,8 +2015,7 @@ void SwAccessibleMap::AddShapeContext(const SdrObject *pObj, uno::Reference < XA if( mpShapeMap ) { - SwAccessibleShapeMap_Impl::value_type aEntry( pObj, xAccShape ); - mpShapeMap->insert( aEntry ); + mpShapeMap->emplace( pObj, xAccShape ); } } @@ -3147,8 +3145,7 @@ bool SwAccessibleMap::ReplaceChild ( } else { - SwAccessibleShapeMap_Impl::value_type aEntry( pObj, xAcc ); - mpShapeMap->insert( aEntry ); + mpShapeMap->emplace( pObj, xAcc ); } } } @@ -3349,14 +3346,12 @@ SwAccessibleSelectedParas_Impl* SwAccessibleMap::BuildSelectedParas() pTextNode == &(pEndPos->nNode.GetNode()) ? pEndPos->nContent.GetIndex() : -1 ); - SwAccessibleSelectedParas_Impl::value_type - aEntry( xWeakAcc, aDataEntry ); if ( !pRetSelectedParas ) { pRetSelectedParas = new SwAccessibleSelectedParas_Impl; } - pRetSelectedParas->insert( aEntry ); + pRetSelectedParas->emplace( xWeakAcc, aDataEntry ); } } } diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 44056b7ee190..1ec347554526 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -3088,8 +3088,7 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL } else { - SwAccessibleHyperTextData::value_type aEntry( pHt, xRet ); - m_pHyperTextData->insert( aEntry ); + m_pHyperTextData->emplace( pHt, xRet ); } } } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 689b032bb3c5..b6586595a32e 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2347,8 +2347,7 @@ lcl_CollectHintSpans(const SwpHints& i_rHints, const sal_Int32 nLength, // no hints at the end (special case: no hints at all in i_rHints) if (nLastEnd != nLength && nLength != 0) { - o_rSpanMap.insert( - AttrSpanMap_t::value_type(AttrSpan_t(nLastEnd, nLength), nullptr)); + o_rSpanMap.emplace(AttrSpan_t(nLastEnd, nLength), nullptr); } } diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 5e62ef00c3c5..82625c6f2864 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1477,7 +1477,7 @@ bool SwContentTree::Expand( SvTreeListEntry* pParent ) assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pChild->GetUserData()))); long nPos = static_cast<SwContent*>(pChild->GetUserData())->GetYPos(); void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos )); - aCurrOutLineNodeMap.insert(std::map<void*, bool>::value_type( key, false ) ); + aCurrOutLineNodeMap.emplace( key, false ); std::map<void*, bool>::iterator iter = mOutLineNodeMap.find( key ); if( iter != mOutLineNodeMap.end() && mOutLineNodeMap[key]) { |