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/drivers/mysql_jdbc/YDriver.cxx | |
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/drivers/mysql_jdbc/YDriver.cxx')
-rw-r--r-- | connectivity/source/drivers/mysql_jdbc/YDriver.cxx | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx index b6345f401615..1f6b595cec03 100644 --- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx +++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx @@ -70,10 +70,8 @@ ODriverDelegator::~ODriverDelegator() { ::comphelper::disposeComponent(m_xODBCDriver); ::comphelper::disposeComponent(m_xNativeDriver); - TJDBCDrivers::iterator aIter = m_aJdbcDrivers.begin(); - TJDBCDrivers::const_iterator aEnd = m_aJdbcDrivers.end(); - for (; aIter != aEnd; ++aIter) - ::comphelper::disposeComponent(aIter->second); + for (auto& rEntry : m_aJdbcDrivers) + ::comphelper::disposeComponent(rEntry.second); } catch (const Exception&) { @@ -350,37 +348,37 @@ ODriverDelegator::getDataDefinitionByConnection(const Reference<XConnection>& co xTunnel->getSomething(OMetaConnection::getUnoTunnelImplementationId())); if (pConnection) { - TWeakPairVector::const_iterator aEnd = m_aConnections.end(); - for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i) + TWeakPairVector::iterator i + = std::find_if(m_aConnections.begin(), m_aConnections.end(), + [&pConnection](const TWeakPairVector::value_type& rConnection) { + return rConnection.second.second == pConnection; + }); + if (i != m_aConnections.end()) { - if (i->second.second == pConnection) + xTab.set(i->second.first.get().get(), UNO_QUERY); + if (!xTab.is()) { - xTab.set(i->second.first.get().get(), UNO_QUERY); - if (!xTab.is()) - { - xTab = new OMySQLCatalog(connection); - i->second.first = WeakReferenceHelper(xTab); - } - break; + xTab = new OMySQLCatalog(connection); + i->second.first = WeakReferenceHelper(xTab); } } } } // if ( xTunnel.is() ) if (!xTab.is()) { - TWeakPairVector::const_iterator aEnd = m_aConnections.end(); - for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i) + TWeakPairVector::iterator i + = std::find_if(m_aConnections.begin(), m_aConnections.end(), + [&connection](const TWeakPairVector::value_type& rConnection) { + Reference<XConnection> xTemp(rConnection.first.get(), UNO_QUERY); + return xTemp == connection; + }); + if (i != m_aConnections.end()) { - Reference<XConnection> xTemp(i->first.get(), UNO_QUERY); - if (xTemp == connection) + xTab.set(i->second.first.get().get(), UNO_QUERY); + if (!xTab.is()) { - xTab.set(i->second.first.get().get(), UNO_QUERY); - if (!xTab.is()) - { - xTab = new OMySQLCatalog(connection); - i->second.first = WeakReferenceHelper(xTab); - } - break; + xTab = new OMySQLCatalog(connection); + i->second.first = WeakReferenceHelper(xTab); } } } |