From 31f96c3e0d13180447c45212158ee69e791c645a Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Sat, 9 Mar 2019 15:54:13 +0300 Subject: 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 --- connectivity/source/drivers/mysql_jdbc/YDriver.cxx | 48 +++++++++++----------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'connectivity/source/drivers/mysql_jdbc/YDriver.cxx') 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& 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 xTemp(rConnection.first.get(), UNO_QUERY); + return xTemp == connection; + }); + if (i != m_aConnections.end()) { - Reference 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); } } } -- cgit