diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-11-24 23:39:59 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-25 12:29:05 +0100 |
commit | 260002b16f18634a7e1d10d4160378beb0cc0c5f (patch) | |
tree | 2528cb63cafa6c8e52ef1537802a737990db3445 /svtools/source | |
parent | 159b30d92f7a17f1d77417a2ed1836ea72699a0e (diff) |
Simplify containers iterations in svgio, svl, svtools
Use range-based loop or replace with STL functions
Change-Id: I98a3e55a14c8ac00188c5003f84194c2cc6795fb
Reviewed-on: https://gerrit.libreoffice.org/63959
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 32 | ||||
-rw-r--r-- | svtools/source/contnr/imivctl1.cxx | 11 | ||||
-rw-r--r-- | svtools/source/control/inettbc.cxx | 14 | ||||
-rw-r--r-- | svtools/source/dialogs/PlaceEditDialog.cxx | 7 | ||||
-rw-r--r-- | svtools/source/dialogs/insdlg.cxx | 15 | ||||
-rw-r--r-- | svtools/source/uno/unocontroltablemodel.cxx | 13 |
6 files changed, 32 insertions, 60 deletions
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index d2dbee92ccbd..01085eef1f67 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -1464,32 +1464,16 @@ void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) // do the filtering - auto aContentLoop = maContent.begin(); - OUString sCompareString; - do - { - if ( (*aContentLoop)->mbIsFolder ) - ++aContentLoop; - else - { + maContent.erase(std::remove_if(maContent.begin(), maContent.end(), + [&aFilters](const std::unique_ptr<SortingData_Impl>& rxContent) { + if (rxContent->mbIsFolder) + return false; // normalize the content title (we always match case-insensitive) // 91872 - 11.09.2001 - frank.schoenheit@sun.com - sCompareString = (*aContentLoop)->GetFileName(); // filter works on file name, not on title! - bool bDelete; - - bDelete = ::std::none_of( aFilters.begin(), aFilters.end(), - FilterMatch( sCompareString ) ); - - if( bDelete ) - { - // none of the filters did match - aContentLoop = maContent.erase(aContentLoop); - } - else - ++aContentLoop; - } - } - while ( aContentLoop != maContent.end() ); + OUString sCompareString = rxContent->GetFileName(); // filter works on file name, not on title! + return std::none_of(aFilters.begin(), aFilters.end(), FilterMatch(sCompareString)); + }), + maContent.end()); } diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 80e9d88a224b..0f11688fe863 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -2036,14 +2036,11 @@ void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry ) && pEntry != maZOrderList.back())) return; - for( auto it = maZOrderList.begin(); it != maZOrderList.end(); ++it) + auto it = std::find(maZOrderList.begin(), maZOrderList.end(), pEntry); + if (it != maZOrderList.end()) { - if ( *it == pEntry ) - { - maZOrderList.erase( it ); - maZOrderList.push_back( pEntry ); - break; - } + maZOrderList.erase( it ); + maZOrderList.push_back( pEntry ); } } diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index ccfb0c021548..5120dfdbb53f 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -1023,9 +1023,12 @@ void SvtMatchContext_Impl::doExecute() aObj.SetSmartProtocol( eSmartProt == INetProtocol::NotValid ? INetProtocol::Http : eSmartProt ); for( ;; ) { - for(std::vector<OUString>::iterator i = aPickList.begin(); schedule() && i != aPickList.end(); ++i) + for(const auto& rPick : aPickList) { - aCurObj.SetURL(*i); + if (!schedule()) + break; + + aCurObj.SetURL(rPick); aCurObj.SetSmartURL( aCurObj.GetURLNoPass()); aCurMainURL = aCurObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); @@ -1264,9 +1267,12 @@ void MatchContext_Impl::doExecute() aObj.SetSmartProtocol( eSmartProt == INetProtocol::NotValid ? INetProtocol::Http : eSmartProt ); for( ;; ) { - for(std::vector<OUString>::iterator i = aPickList.begin(); schedule() && i != aPickList.end(); ++i) + for(const auto& rPick : aPickList) { - aCurObj.SetURL(*i); + if (!schedule()) + break; + + aCurObj.SetURL(rPick); aCurObj.SetSmartURL( aCurObj.GetURLNoPass()); aCurMainURL = aCurObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx index 069a165dc6aa..dfaba1f22488 100644 --- a/svtools/source/dialogs/PlaceEditDialog.cxx +++ b/svtools/source/dialogs/PlaceEditDialog.cxx @@ -318,11 +318,10 @@ IMPL_LINK_NOARG( PlaceEditDialog, EditLabelHdl, weld::Entry&, void ) IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl, weld::Entry&, void ) { - for ( std::vector< std::shared_ptr< DetailsContainer > >::iterator it = m_aDetailsContainers.begin( ); - it != m_aDetailsContainers.end( ); ++it ) + for ( auto& rxDetailsContainer : m_aDetailsContainers ) { - ( *it )->setUsername( m_xEDUsername->get_text() ); - ( *it )->setPassword( m_xEDPassword->get_text() ); + rxDetailsContainer->setUsername( m_xEDUsername->get_text() ); + rxDetailsContainer->setPassword( m_xEDPassword->get_text() ); } EditHdl(nullptr); diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx index bb0ea1f07393..01f699d4b835 100644 --- a/svtools/source/dialogs/insdlg.cxx +++ b/svtools/source/dialogs/insdlg.cxx @@ -78,18 +78,9 @@ const SvObjectServer * SvObjectServerList::Get( const SvGlobalName & rName ) con void SvObjectServerList::Remove( const SvGlobalName & rName ) { - for( size_t i = 0; i < aObjectServerList.size(); ) - { - if( aObjectServerList[ i ].GetClassName() == rName ) - { - SvObjectServerList_impl::iterator it = aObjectServerList.begin() + i; - aObjectServerList.erase( it ); - } - else - { - ++i; - } - } + aObjectServerList.erase(std::remove_if(aObjectServerList.begin(), aObjectServerList.end(), + [rName](const SvObjectServer& rServer) { return rServer.GetClassName() == rName; }), + aObjectServerList.end()); } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 238aa92a9a08..c0aad3af8a8c 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -390,16 +390,11 @@ namespace svt { namespace table void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener ) { DBG_CHECK_ME(); - for ( ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin(); - lookup != m_pImpl->m_aListeners.end(); - ++lookup - ) + auto lookup = std::find(m_pImpl->m_aListeners.begin(), m_pImpl->m_aListeners.end(), i_listener); + if (lookup != m_pImpl->m_aListeners.end()) { - if ( *lookup == i_listener ) - { - m_pImpl->m_aListeners.erase( lookup ); - return; - } + m_pImpl->m_aListeners.erase( lookup ); + return; } OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" ); } |