diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-10-20 22:15:25 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-22 09:47:59 +0200 |
commit | e06afb0c9546ddcde1cedd75f59001396ac6fdf2 (patch) | |
tree | c5e60976b74bd102bff3e58381e53bb949c6ea22 /ucbhelper | |
parent | 8959bb300b05be9fafbf30e553b35fb517bdf786 (diff) |
Simplify containers iterations in ucb, ucbhelper
Use range-based loop or replace with STL functions.
Change-Id: I3cdb0f89523008199af1550de164a52b75c52ba5
Reviewed-on: https://gerrit.libreoffice.org/62088
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/client/interceptedinteraction.cxx | 35 | ||||
-rw-r--r-- | ucbhelper/source/provider/providerhelper.cxx | 10 |
2 files changed, 13 insertions, 32 deletions
diff --git a/ucbhelper/source/client/interceptedinteraction.cxx b/ucbhelper/source/client/interceptedinteraction.cxx index 0f48f4c4f77f..69aab5110ab5 100644 --- a/ucbhelper/source/client/interceptedinteraction.cxx +++ b/ucbhelper/source/client/interceptedinteraction.cxx @@ -104,37 +104,24 @@ InterceptedInteraction::EInterceptionState InterceptedInteraction::impl_intercep css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations(); // check against the list of static requests - sal_Int32 nHandle = 0; - ::std::vector< InterceptedRequest >::const_iterator pIt; - for ( pIt = m_lInterceptions.begin(); - pIt != m_lInterceptions.end() ; - ++pIt ) + auto pIt = std::find_if(m_lInterceptions.begin(), m_lInterceptions.end(), + [&aRequestType](const InterceptedRequest& rInterception) { + // check the request + // don't change intercepted and request type here -> it will check the wrong direction! + return rInterception.Request.getValueType().isAssignableFrom(aRequestType); + }); + + if (pIt != m_lInterceptions.end()) // intercepted ... { const InterceptedRequest& rInterception = *pIt; - css::uno::Type aInterceptedType = rInterception.Request.getValueType(); - // check the request - bool bMatch = aInterceptedType.isAssignableFrom(aRequestType); // don't change intercepted and request type here -> it will check the wrong direction! - - // intercepted ... // Call they might existing derived class, so they can handle that by its own. // If it's not interested on that (maybe it's not overwritten and the default implementation - // returns E_NOT_INTERCEPTED as default) -> break this loop and search for the right continuation. - if (bMatch) - { - EInterceptionState eState = intercepted(rInterception, xRequest); - if (eState == E_NOT_INTERCEPTED) - break; + // returns E_NOT_INTERCEPTED as default) -> search required continuation + EInterceptionState eState = intercepted(rInterception, xRequest); + if (eState != E_NOT_INTERCEPTED) return eState; - } - ++nHandle; - } - - if (pIt != m_lInterceptions.end()) // => can be true only if bMatch=TRUE! - { - // match -> search required continuation - const InterceptedRequest& rInterception = *pIt; css::uno::Reference< css::task::XInteractionContinuation > xContinuation = InterceptedInteraction::extractContinuation(lContinuations, rInterception.Continuation); if (xContinuation.is()) { diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx index 903587b95e74..766c6ebd3dd5 100644 --- a/ucbhelper/source/provider/providerhelper.cxx +++ b/ucbhelper/source/provider/providerhelper.cxx @@ -196,20 +196,14 @@ void ContentProviderImplHelper::queryExistingContents( cleanupRegisteredContents(); - ucbhelper_impl::Contents::const_iterator it - = m_pImpl->m_aContents.begin(); - ucbhelper_impl::Contents::const_iterator end - = m_pImpl->m_aContents.end(); - - while ( it != end ) + for ( const auto& rContent : m_pImpl->m_aContents ) { - uno::Reference< ucb::XContent > xContent( (*it).second ); + uno::Reference< ucb::XContent > xContent( rContent.second ); if ( xContent.is() ) { rContents.emplace_back( static_cast< ContentImplHelper * >( xContent.get() ) ); } - ++it; } } |