diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-11-27 22:17:40 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-29 12:06:44 +0100 |
commit | 0ded54c33f01d18d2cd06547bd8307bd140cf28f (patch) | |
tree | e250a9a8bb89b2042d9a0bc09f80bf65757eec19 /stoc | |
parent | 7d311ea864e7cfeb1c8f4ca417911db20d13361e (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 'stoc')
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 10 | ||||
-rw-r--r-- | stoc/source/invocation_adapterfactory/iafactory.cxx | 7 | ||||
-rw-r--r-- | stoc/source/servicemanager/servicemanager.cxx | 10 | ||||
-rw-r--r-- | stoc/source/simpleregistry/simpleregistry.cxx | 5 |
4 files changed, 12 insertions, 20 deletions
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 02706a6258de..53e045c6dc2b 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -1505,12 +1505,10 @@ public: typename Map::size_type const MAX = 100; assert(map_.size() <= MAX); if (map_.size() == MAX) { - typename Map::iterator del(map_.begin()); - for (typename Map::iterator i(map_.begin()); i != map_.end(); ++i) { - if (i->second.hits < del->second.hits) { - del = i; - } - } + typename Map::iterator del = std::min_element(map_.begin(), map_.end(), + [](const typename Map::value_type& a, const typename Map::value_type& b) { + return a.second.hits < b.second.hits; + }); map_.erase(del); } bool ins = map_.emplace(key, Data(access)).second; diff --git a/stoc/source/invocation_adapterfactory/iafactory.cxx b/stoc/source/invocation_adapterfactory/iafactory.cxx index 52d2eb3ff2d5..cca99f1ebf20 100644 --- a/stoc/source/invocation_adapterfactory/iafactory.cxx +++ b/stoc/source/invocation_adapterfactory/iafactory.cxx @@ -766,11 +766,9 @@ static AdapterImpl * lookup_adapter( // find matching adapter Type const * pTypes = rTypes.getConstArray(); sal_Int32 nTypes = rTypes.getLength(); - t_ptr_set::const_iterator iPos( adapters_set.begin() ); - t_ptr_set::const_iterator const iEnd( adapters_set.end() ); - while (iEnd != iPos) + for (const auto& rpAdapter : adapters_set) { - AdapterImpl * that = static_cast< AdapterImpl * >( *iPos ); + AdapterImpl * that = static_cast< AdapterImpl * >( rpAdapter ); // iterate through all types if that is a matching adapter sal_Int32 nPosTypes; for ( nPosTypes = nTypes; nPosTypes--; ) @@ -793,7 +791,6 @@ static AdapterImpl * lookup_adapter( } if (nPosTypes < 0) // all types found return that; - ++iPos; } return nullptr; } diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 43aadfff0fbf..39ea85c5a833 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -640,12 +640,11 @@ void OServiceManager::disposing() m_bInDisposing = true; aImpls = m_ImplementationMap; } - HashSet_Ref::iterator aIt = aImpls.begin(); - while( aIt != aImpls.end() ) + for( const auto& rxImpl : aImpls ) { try { - Reference<XComponent > xComp( Reference<XComponent >::query( *aIt++ ) ); + Reference<XComponent > xComp( Reference<XComponent >::query( rxImpl ) ); if( xComp.is() ) xComp->dispose(); } @@ -779,9 +778,8 @@ Sequence< OUString > OServiceManager::getUniqueAvailableServiceNames( { check_undisposed(); MutexGuard aGuard( m_mutex ); - HashMultimap_OWString_Interface::iterator aSIt = m_ServiceMap.begin(); - while( aSIt != m_ServiceMap.end() ) - aNameSet.insert( (*aSIt++).first ); + for( const auto& rEntry : m_ServiceMap ) + aNameSet.insert( rEntry.first ); /* do not return the implementation names HashMap_OWString_Interface m_ImplementationNameMap; diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 0c20d6b5d0bc..ff5e1444cdb6 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -489,10 +489,9 @@ void Key::setAsciiListValue( list.push_back(utf8); } std::vector< char * > list2; - for (std::vector< OString >::iterator i(list.begin()); i != list.end(); - ++i) + for (const auto& rItem : list) { - list2.push_back(const_cast< char * >(i->getStr())); + list2.push_back(const_cast< char * >(rItem.getStr())); } RegError err = key_.setStringListValue( OUString(), list2.data(), static_cast< sal_uInt32 >(list2.size())); |