summaryrefslogtreecommitdiff
path: root/sot
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-11-27 22:17:40 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-29 12:06:44 +0100
commit0ded54c33f01d18d2cd06547bd8307bd140cf28f (patch)
treee250a9a8bb89b2042d9a0bc09f80bf65757eec19 /sot
parent7d311ea864e7cfeb1c8f4ca417911db20d13361e (diff)
Simplify containers iterations in slideshow, sot, starmath, stoc
Use range-based loop or replace with STL functions Change-Id: I94792c28b283a0998bf813317e5beb37d93e0c23 Reviewed-on: https://gerrit.libreoffice.org/64125 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sot')
-rw-r--r--sot/qa/cppunit/test_sot.cxx11
-rw-r--r--sot/source/base/formats.cxx16
-rw-r--r--sot/source/sdstor/stgcache.cxx31
3 files changed, 21 insertions, 37 deletions
diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx
index 57c636de0df5..06e26c806eb1 100644
--- a/sot/qa/cppunit/test_sot.cxx
+++ b/sot/qa/cppunit/test_sot.cxx
@@ -107,16 +107,15 @@ namespace
SvStorageInfoList aInfoList;
xObjStor->FillInfoList( &aInfoList );
- for( SvStorageInfoList::iterator aIt = aInfoList.begin();
- aIt != aInfoList.end(); ++aIt )
+ for (auto& rInfo : aInfoList)
{
- if( aIt->IsStorage() )
+ if( rInfo.IsStorage() )
{
- tools::SvRef<SotStorage> xChild( xObjStor->OpenSotStorage( aIt->GetName() ) );
+ tools::SvRef<SotStorage> xChild( xObjStor->OpenSotStorage( rInfo.GetName() ) );
checkStorage( xChild );
}
- else if( aIt->IsStream() )
- checkStream( xObjStor, aIt->GetName(), aIt->GetSize() );
+ else if( rInfo.IsStream() )
+ checkStream( xObjStor, rInfo.GetName(), rInfo.GetSize() );
}
return true;
diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx
index 9b7770f146ef..cc8ea22feaaa 100644
--- a/sot/source/base/formats.cxx
+++ b/sot/source/base/formats.cxx
@@ -1318,20 +1318,8 @@ const SotAction_Impl* GetExchangeDestinationWriterFreeAreaCopy()
bool IsFormatSupported( const DataFlavorExVector& rDataFlavorExVector, SotClipboardFormatId nId )
{
- auto aIter( rDataFlavorExVector.begin() );
- auto aEnd( rDataFlavorExVector.end() );
- bool bRet = false;
-
- while( aIter != aEnd )
- {
- if( nId == (*aIter++).mnSotId )
- {
- bRet = true;
- aIter = aEnd;
- }
- }
-
- return bRet;
+ return std::any_of(rDataFlavorExVector.begin(), rDataFlavorExVector.end(),
+ [nId](const DataFlavorEx& rDataFlavorEx) { return nId == rDataFlavorEx.mnSotId; });
}
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx
index 532b74e3d501..5c03f89cc4fd 100644
--- a/sot/source/sdstor/stgcache.cxx
+++ b/sot/source/sdstor/stgcache.cxx
@@ -131,12 +131,10 @@ void StgCache::Erase( const rtl::Reference< StgPage > &xElem )
{
OSL_ENSURE( xElem.is(), "The pointer should not be NULL!" );
if ( xElem.is() ) {
- for ( LRUList::iterator it = maLRUPages.begin(); it != maLRUPages.end(); ++it ) {
- if ( it->is() && (*it)->GetPage() == xElem->GetPage() ) {
- it->clear();
- break;
- }
- }
+ auto it = std::find_if(maLRUPages.begin(), maLRUPages.end(),
+ [xElem](const rtl::Reference<StgPage>& rxPage) { return rxPage.is() && rxPage->GetPage() == xElem->GetPage(); });
+ if (it != maLRUPages.end())
+ it->clear();
}
}
@@ -145,17 +143,18 @@ void StgCache::Erase( const rtl::Reference< StgPage > &xElem )
void StgCache::Clear()
{
maDirtyPages.clear();
- for ( LRUList::iterator it = maLRUPages.begin(); it != maLRUPages.end(); ++it )
- it->clear();
+ for (auto& rxPage : maLRUPages)
+ rxPage.clear();
}
// Look for a cached page
rtl::Reference< StgPage > StgCache::Find( sal_Int32 nPage )
{
- for ( LRUList::iterator it = maLRUPages.begin(); it != maLRUPages.end(); ++it )
- if ( it->is() && (*it)->GetPage() == nPage )
- return *it;
+ auto it = std::find_if(maLRUPages.begin(), maLRUPages.end(),
+ [nPage](const rtl::Reference<StgPage>& rxPage) { return rxPage.is() && rxPage->GetPage() == nPage; });
+ if (it != maLRUPages.end())
+ return *it;
IndexToStgPage::iterator it2 = maDirtyPages.find( nPage );
if ( it2 != maDirtyPages.end() )
return it2->second;
@@ -211,15 +210,13 @@ bool StgCache::Commit()
if ( Good() ) // otherwise Write does nothing
{
std::vector< StgPage * > aToWrite;
- for ( IndexToStgPage::iterator aIt = maDirtyPages.begin();
- aIt != maDirtyPages.end(); ++aIt )
- aToWrite.push_back( aIt->second.get() );
+ for (const auto& rEntry : maDirtyPages)
+ aToWrite.push_back( rEntry.second.get() );
std::sort( aToWrite.begin(), aToWrite.end(), StgPage::IsPageGreater );
- for ( std::vector< StgPage * >::iterator aWr = aToWrite.begin();
- aWr != aToWrite.end(); ++aWr)
+ for (StgPage* pWr : aToWrite)
{
- const rtl::Reference< StgPage > &pPage = *aWr;
+ const rtl::Reference< StgPage > &pPage = pWr;
if ( !Write( pPage->GetPage(), pPage->GetData() ) )
return false;
}