diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-03-09 15:54:13 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-09 18:31:12 +0100 |
commit | 31f96c3e0d13180447c45212158ee69e791c645a (patch) | |
tree | 3ec7744b25a3929cafd4bbdffd018a5036055ad7 /connectivity/source/cpool | |
parent | 4e25914b165d7ed64b3026af758fb857676aacd5 (diff) |
Simplify containers iterations in connectivity
Use range-based loop or replace with STL functions
Change-Id: I1f7c1ea19cdc8d450b7ed88a663ba9ccb3249304
Reviewed-on: https://gerrit.libreoffice.org/68974
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source/cpool')
-rw-r--r-- | connectivity/source/cpool/ZConnectionPool.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/cpool/ZPoolCollection.cxx | 20 |
2 files changed, 10 insertions, 20 deletions
diff --git a/connectivity/source/cpool/ZConnectionPool.cxx b/connectivity/source/cpool/ZConnectionPool.cxx index c1c3cf44322e..7ac1845911a1 100644 --- a/connectivity/source/cpool/ZConnectionPool.cxx +++ b/connectivity/source/cpool/ZConnectionPool.cxx @@ -237,13 +237,9 @@ void OConnectionPool::invalidatePooledConnections() aIter->second.aConnections.clear(); // look if the iterator aIter is still present in the active connection map - TActiveConnectionMap::const_iterator aActIter = m_aActiveConnections.begin(); - for (; aActIter != m_aActiveConnections.end(); ++aActIter) - { - if(aIter == aActIter->second.aPos) - break; - } - if(aActIter == m_aActiveConnections.end()) + bool isPresent = std::any_of(m_aActiveConnections.begin(), m_aActiveConnections.end(), + [&aIter](const TActiveConnectionMap::value_type& rEntry) { return rEntry.second.aPos == aIter; }); + if(!isPresent) {// he isn't so we can delete him aIter = m_aPool.erase(aIter); } diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx index 86393c6319ce..7ae66038bdf7 100644 --- a/connectivity/source/cpool/ZPoolCollection.cxx +++ b/connectivity/source/cpool/ZPoolCollection.cxx @@ -181,15 +181,12 @@ Reference< XDriver > SAL_CALL OPoolCollection::getDriverByURL( const OUString& _ { Reference< XDriver > xExistentProxy; // look if we already have a proxy for this driver - for ( MapDriver2DriverRef::const_iterator aLookup = m_aDriverProxies.begin(); - aLookup != m_aDriverProxies.end(); - ++aLookup - ) + for (const auto& [rxDriver, rxDriverRef] : m_aDriverProxies) { // hold the proxy alive as long as we're in this loop round - xExistentProxy = aLookup->second; + xExistentProxy = rxDriverRef; - if (xExistentProxy.is() && (aLookup->first.get() == xDriver.get())) + if (xExistentProxy.is() && (rxDriver.get() == xDriver.get())) // already created a proxy for this break; } @@ -284,11 +281,9 @@ bool OPoolCollection::isPoolingEnabledByUrl(const OUString& _sUrl, void OPoolCollection::clearConnectionPools(bool _bDispose) { - OConnectionPools::const_iterator aIter = m_aPools.begin(); - while(aIter != m_aPools.end()) + for(auto& rEntry : m_aPools) { - aIter->second->clear(_bDispose); - ++aIter; + rEntry.second->clear(_bDispose); } m_aPools.clear(); } @@ -442,10 +437,9 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE { m_aDriverProxies.clear(); m_aDriverProxies = MapDriver2DriverRef(); - OConnectionPools::iterator aIter = m_aPools.begin(); - for(;aIter != m_aPools.end();++aIter) + for(auto& rEntry : m_aPools) { - aIter->second->clear(false); + rEntry.second->clear(false); } m_aPools.clear(); } |