Kaydet (Commit) 5af9e26a authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

Simplify containers iterations in cppcanvas, cppu, cppuhelper

Use range-based loop or replace with STL functions

Change-Id: I72bf7cdb632c04e2fc8d4f7ab85cb6571222aa07
Reviewed-on: https://gerrit.libreoffice.org/68636
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 20b1a458
...@@ -2025,13 +2025,11 @@ namespace cppcanvas ...@@ -2025,13 +2025,11 @@ namespace cppcanvas
aMapModeTransform.set(0,2, 0.0); aMapModeTransform.set(0,2, 0.0);
aMapModeTransform.set(1,2, 0.0); aMapModeTransform.set(1,2, 0.0);
PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() ); for( const auto& rVCLPolyPolygon : aVCLPolyPolyVector )
const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() );
for( ; aIter!= aEnd; ++aIter )
{ {
::basegfx::B2DPolyPolygon aPolyPolygon; ::basegfx::B2DPolyPolygon aPolyPolygon;
aPolyPolygon = aIter->getB2DPolyPolygon(); aPolyPolygon = rVCLPolyPolygon.getB2DPolyPolygon();
aPolyPolygon.transform( aMapModeTransform ); aPolyPolygon.transform( aMapModeTransform );
// append result to collecting polypoly // append result to collecting polypoly
......
...@@ -129,13 +129,11 @@ namespace cppu_threadpool { ...@@ -129,13 +129,11 @@ namespace cppu_threadpool {
void JobQueue::dispose( sal_Int64 nDisposeId ) void JobQueue::dispose( sal_Int64 nDisposeId )
{ {
MutexGuard guard( m_mutex ); MutexGuard guard( m_mutex );
for( auto ii = m_lstCallstack.begin() ; for( auto& rId : m_lstCallstack )
ii != m_lstCallstack.end() ;
++ii )
{ {
if( (*ii) == nDisposeId ) if( rId == nDisposeId )
{ {
(*ii) = 0; rId = 0;
} }
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <algorithm>
#include <unordered_map> #include <unordered_map>
#include <cassert> #include <cassert>
#include <list> #include <list>
...@@ -223,14 +224,11 @@ inline void TypeDescriptor_Init_Impl::callChain( ...@@ -223,14 +224,11 @@ inline void TypeDescriptor_Init_Impl::callChain(
assert(*ppRet == nullptr); assert(*ppRet == nullptr);
if (pCallbacks) if (pCallbacks)
{ {
CallbackSet_Impl::const_iterator aIt = pCallbacks->begin(); for( const CallbackEntry & rEntry : *pCallbacks )
while( aIt != pCallbacks->end() )
{ {
const CallbackEntry & rEntry = *aIt;
(*rEntry.second)( rEntry.first, ppRet, pName ); (*rEntry.second)( rEntry.first, ppRet, pName );
if( *ppRet ) if( *ppRet )
return; return;
++aIt;
} }
} }
} }
...@@ -240,11 +238,9 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() ...@@ -240,11 +238,9 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
{ {
if( pCache ) if( pCache )
{ {
TypeDescriptionList_Impl::const_iterator aIt = pCache->begin(); for( typelib_TypeDescription* pItem : *pCache )
while( aIt != pCache->end() )
{ {
typelib_typedescription_release( *aIt ); typelib_typedescription_release( pItem );
++aIt;
} }
} }
...@@ -254,19 +250,14 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() ...@@ -254,19 +250,14 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
ppTDR.reserve( pWeakMap->size() ); ppTDR.reserve( pWeakMap->size() );
// save all weak references // save all weak references
WeakMap_Impl::const_iterator aIt = pWeakMap->begin(); for( const auto& rEntry : *pWeakMap )
while( aIt != pWeakMap->end() )
{ {
ppTDR.push_back( (*aIt).second ); ppTDR.push_back( rEntry.second );
typelib_typedescriptionreference_acquire( ppTDR.back() ); typelib_typedescriptionreference_acquire( ppTDR.back() );
++aIt;
} }
for( std::vector< typelib_TypeDescriptionReference * >::iterator i( for( typelib_TypeDescriptionReference * pTDR : ppTDR )
ppTDR.begin() );
i != ppTDR.end(); ++i )
{ {
typelib_TypeDescriptionReference * pTDR = *i;
OSL_ASSERT( pTDR->nRefCount > pTDR->nStaticRefCount ); OSL_ASSERT( pTDR->nRefCount > pTDR->nStaticRefCount );
pTDR->nRefCount -= pTDR->nStaticRefCount; pTDR->nRefCount -= pTDR->nStaticRefCount;
...@@ -278,11 +269,10 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() ...@@ -278,11 +269,10 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
typelib_typedescriptionreference_release( pTDR ); typelib_typedescriptionreference_release( pTDR );
} }
aIt = pWeakMap->begin();
#if defined SAL_LOG_INFO #if defined SAL_LOG_INFO
while( aIt != pWeakMap->end() ) for( const auto& rEntry : *pWeakMap )
{ {
typelib_TypeDescriptionReference * pTDR = (*aIt).second; typelib_TypeDescriptionReference * pTDR = rEntry.second;
if (pTDR) if (pTDR)
{ {
OString aTypeName( OUStringToOString( pTDR->pTypeName, RTL_TEXTENCODING_ASCII_US ) ); OString aTypeName( OUStringToOString( pTDR->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
...@@ -292,7 +282,6 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() ...@@ -292,7 +282,6 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
{ {
SAL_INFO("cppu.typelib", "remaining null type entry!?"); SAL_INFO("cppu.typelib", "remaining null type entry!?");
} }
++aIt;
} }
#endif #endif
} }
...@@ -336,18 +325,8 @@ extern "C" void SAL_CALL typelib_typedescription_revokeCallback( ...@@ -336,18 +325,8 @@ extern "C" void SAL_CALL typelib_typedescription_revokeCallback(
// todo mt safe: guard is no solution, can not acquire while calling callback! // todo mt safe: guard is no solution, can not acquire while calling callback!
// OslGuard aGuard( rInit.getMutex() ); // OslGuard aGuard( rInit.getMutex() );
CallbackEntry aEntry( pContext, pCallback ); CallbackEntry aEntry( pContext, pCallback );
CallbackSet_Impl::iterator iPos( rInit.pCallbacks->begin() ); rInit.pCallbacks->erase(std::remove(rInit.pCallbacks->begin(), rInit.pCallbacks->end(), aEntry),
while (iPos != rInit.pCallbacks->end()) rInit.pCallbacks->end());
{
if (*iPos == aEntry)
{
iPos = rInit.pCallbacks->erase(iPos);
}
else
{
++iPos;
}
}
} }
} }
...@@ -1018,21 +997,20 @@ extern "C" void SAL_CALL typelib_typedescription_newMIInterface( ...@@ -1018,21 +997,20 @@ extern "C" void SAL_CALL typelib_typedescription_newMIInterface(
sal_Int32 n = 0; sal_Int32 n = 0;
BaseList::List const & rList = aBaseList.getList(); BaseList::List const & rList = aBaseList.getList();
for (BaseList::List::const_iterator i(rList.begin()); i != rList.end(); for (const auto& rEntry : rList)
++i)
{ {
typelib_InterfaceTypeDescription const * pBase = i->base; typelib_InterfaceTypeDescription const * pBase = rEntry.base;
typelib_InterfaceTypeDescription const * pDirectBase typelib_InterfaceTypeDescription const * pDirectBase
= pITD->ppBaseTypes[i->directBaseIndex]; = pITD->ppBaseTypes[rEntry.directBaseIndex];
OSL_ASSERT(pBase->ppAllMembers != nullptr); OSL_ASSERT(pBase->ppAllMembers != nullptr);
for (sal_Int32 j = 0; j < pBase->nMembers; ++j) { for (sal_Int32 j = 0; j < pBase->nMembers; ++j) {
typelib_TypeDescriptionReference const * pDirectBaseMember typelib_TypeDescriptionReference const * pDirectBaseMember
= pDirectBase->ppAllMembers[i->directBaseMemberOffset + j]; = pDirectBase->ppAllMembers[rEntry.directBaseMemberOffset + j];
OUStringBuffer aBuf(pDirectBaseMember->pTypeName); OUStringBuffer aBuf(pDirectBaseMember->pTypeName);
aBuf.append(":@"); aBuf.append(":@");
aBuf.append(i->directBaseIndex); aBuf.append(rEntry.directBaseIndex);
aBuf.append(','); aBuf.append(',');
aBuf.append(i->memberOffset + j); aBuf.append(rEntry.memberOffset + j);
aBuf.append(':'); aBuf.append(':');
aBuf.append(pITD->aBase.pTypeName); aBuf.append(pITD->aBase.pTypeName);
OUString aName(aBuf.makeStringAndClear()); OUString aName(aBuf.makeStringAndClear());
......
...@@ -495,12 +495,9 @@ static void defenv_getRegisteredInterfaces( ...@@ -495,12 +495,9 @@ static void defenv_getRegisteredInterfaces(
sal_Int32 nPos = 0; sal_Int32 nPos = 0;
void ** ppInterfaces = static_cast<void **>((*memAlloc)( nLen * sizeof (void *) )); void ** ppInterfaces = static_cast<void **>((*memAlloc)( nLen * sizeof (void *) ));
Ptr2ObjectMap::const_iterator iPos( that->aPtr2ObjectMap.begin() ); for (const auto& rEntry : that->aPtr2ObjectMap)
Ptr2ObjectMap::const_iterator const iEnd( that->aPtr2ObjectMap.end() );
while (iPos != iEnd)
{ {
(*pEnv->acquireInterface)( pEnv, ppInterfaces[nPos++] = (*iPos).first ); (*pEnv->acquireInterface)( pEnv, ppInterfaces[nPos++] = rEntry.first );
++iPos;
} }
*pppInterfaces = ppInterfaces; *pppInterfaces = ppInterfaces;
...@@ -711,10 +708,9 @@ extern "C" void SAL_CALL uno_dumpEnvironment( ...@@ -711,10 +708,9 @@ extern "C" void SAL_CALL uno_dumpEnvironment(
::osl::MutexGuard guard( that->mutex ); ::osl::MutexGuard guard( that->mutex );
Ptr2ObjectMap ptr2obj( that->aPtr2ObjectMap ); Ptr2ObjectMap ptr2obj( that->aPtr2ObjectMap );
OId2ObjectMap::const_iterator iPos( that->aOId2ObjectMap.begin() ); for (const auto& rEntry : that->aOId2ObjectMap)
while (iPos != that->aOId2ObjectMap.end())
{ {
ObjectEntry * pOEntry = iPos->second; ObjectEntry * pOEntry = rEntry.second;
buf.append( "+ " ); buf.append( "+ " );
if (pOEntry->mixedObject) if (pOEntry->mixedObject)
...@@ -757,7 +753,6 @@ extern "C" void SAL_CALL uno_dumpEnvironment( ...@@ -757,7 +753,6 @@ extern "C" void SAL_CALL uno_dumpEnvironment(
} }
writeLine( stream, buf.makeStringAndClear(), pFilter ); writeLine( stream, buf.makeStringAndClear(), pFilter );
} }
++iPos;
} }
if (! ptr2obj.empty()) if (! ptr2obj.empty())
writeLine( stream, "ptr map inconsistency!!!", pFilter ); writeLine( stream, "ptr map inconsistency!!!", pFilter );
...@@ -893,10 +888,9 @@ EnvironmentsData::~EnvironmentsData() ...@@ -893,10 +888,9 @@ EnvironmentsData::~EnvironmentsData()
::osl::MutexGuard guard( mutex ); ::osl::MutexGuard guard( mutex );
isDisposing = true; isDisposing = true;
for ( OUString2EnvironmentMap::const_iterator iPos( aName2EnvMap.begin() ); for ( const auto& rEntry : aName2EnvMap )
iPos != aName2EnvMap.end(); ++iPos )
{ {
uno_Environment * pWeak = iPos->second; uno_Environment * pWeak = rEntry.second;
uno_Environment * pHard = nullptr; uno_Environment * pHard = nullptr;
(*pWeak->harden)( &pHard, pWeak ); (*pWeak->harden)( &pHard, pWeak );
(*pWeak->releaseWeak)( pWeak ); (*pWeak->releaseWeak)( pWeak );
...@@ -982,10 +976,9 @@ void EnvironmentsData::getRegisteredEnvironments( ...@@ -982,10 +976,9 @@ void EnvironmentsData::getRegisteredEnvironments(
sal_Int32 nSize = 0; sal_Int32 nSize = 0;
// find matching environment // find matching environment
for ( OUString2EnvironmentMap::const_iterator iPos( aName2EnvMap.begin() ); for ( const auto& rEntry : aName2EnvMap )
iPos != aName2EnvMap.end(); ++iPos )
{ {
uno_Environment * pWeak = iPos->second; uno_Environment * pWeak = rEntry.second;
if (rEnvDcp.isEmpty() || if (rEnvDcp.isEmpty() ||
rEnvDcp == pWeak->pTypeName ) rEnvDcp == pWeak->pTypeName )
{ {
......
...@@ -608,10 +608,9 @@ void SAL_CALL uno_getMapping( ...@@ -608,10 +608,9 @@ void SAL_CALL uno_getMapping(
if (! aRet.is()) // try callback chain if (! aRet.is()) // try callback chain
{ {
MutexGuard aGuard( rData.aCallbacksMutex ); MutexGuard aGuard( rData.aCallbacksMutex );
for ( t_CallbackSet::const_iterator iPos( rData.aCallbacks.begin() ); for ( const auto& rCallback : rData.aCallbacks )
iPos != rData.aCallbacks.end(); ++iPos )
{ {
(**iPos)( ppMapping, pFrom, pTo, aAddPurpose.pData ); (*rCallback)( ppMapping, pFrom, pTo, aAddPurpose.pData );
if (*ppMapping) if (*ppMapping)
return; return;
} }
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/uno/DeploymentException.hpp>
#include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/RuntimeException.hpp>
#include <comphelper/sequence.hxx>
#include <memory> #include <memory>
#define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager" #define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager"
...@@ -232,14 +234,7 @@ Any ComponentContext::getByName( OUString const & name ) ...@@ -232,14 +234,7 @@ Any ComponentContext::getByName( OUString const & name )
Sequence<OUString> ComponentContext::getElementNames() Sequence<OUString> ComponentContext::getElementNames()
{ {
MutexGuard guard( m_mutex ); MutexGuard guard( m_mutex );
Sequence<OUString> ret( m_map.size() ); return comphelper::mapKeysToSequence(m_map);
OUString * pret = ret.getArray();
sal_Int32 pos = 0;
t_map::const_iterator iPos( m_map.begin() );
t_map::const_iterator const iEnd( m_map.end() );
for ( ; iPos != iEnd; ++iPos )
pret[pos++] = iPos->first;
return ret;
} }
...@@ -393,16 +388,12 @@ void ComponentContext::disposing() ...@@ -393,16 +388,12 @@ void ComponentContext::disposing()
Reference< lang::XComponent > xTDMgr, xAC; // to be disposed separately Reference< lang::XComponent > xTDMgr, xAC; // to be disposed separately
// dispose all context objects // dispose all context objects
t_map::iterator iPos( m_map.begin() ); for ( auto& [rName, rEntry] : m_map )
t_map::iterator const iEnd( m_map.end() );
for ( ; iPos != iEnd; ++iPos )
{ {
// service manager disposed separately // service manager disposed separately
if (!m_xSMgr.is() || if (!m_xSMgr.is() ||
!iPos->first.startsWith( SMGR_SINGLETON )) !rName.startsWith( SMGR_SINGLETON ))
{ {
ContextEntry& rEntry = iPos->second;
if (rEntry.lateInit) if (rEntry.lateInit)
{ {
// late init // late init
...@@ -419,11 +410,11 @@ void ComponentContext::disposing() ...@@ -419,11 +410,11 @@ void ComponentContext::disposing()
rEntry.value >>= xComp; rEntry.value >>= xComp;
if (xComp.is()) if (xComp.is())
{ {
if ( iPos->first == TDMGR_SINGLETON ) if ( rName == TDMGR_SINGLETON )
{ {
xTDMgr = xComp; xTDMgr = xComp;
} }
else if ( iPos->first == AC_SINGLETON ) else if ( rName == AC_SINGLETON )
{ {
xAC = xComp; xAC = xComp;
} }
......
...@@ -332,14 +332,11 @@ OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex & ...@@ -332,14 +332,11 @@ OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex &
OMultiTypeInterfaceContainerHelper::~OMultiTypeInterfaceContainerHelper() OMultiTypeInterfaceContainerHelper::~OMultiTypeInterfaceContainerHelper()
{ {
t_type2ptr * pMap = static_cast<t_type2ptr *>(m_pMap); t_type2ptr * pMap = static_cast<t_type2ptr *>(m_pMap);
t_type2ptr::iterator iter = pMap->begin();
t_type2ptr::iterator end = pMap->end();
while( iter != end ) for (auto& rItem : *pMap)
{ {
delete static_cast<OInterfaceContainerHelper*>((*iter).second); delete static_cast<OInterfaceContainerHelper*>(rItem.second);
(*iter).second = nullptr; rItem.second = nullptr;
++iter;
} }
delete pMap; delete pMap;
} }
...@@ -356,17 +353,13 @@ Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const ...@@ -356,17 +353,13 @@ Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const
css::uno::Sequence< Type > aInterfaceTypes( nSize ); css::uno::Sequence< Type > aInterfaceTypes( nSize );
Type * pArray = aInterfaceTypes.getArray(); Type * pArray = aInterfaceTypes.getArray();
t_type2ptr::iterator iter = pMap->begin();
t_type2ptr::iterator end = pMap->end();
sal_Int32 i = 0; sal_Int32 i = 0;
while( iter != end ) for (const auto& rItem : *pMap)
{ {
// are interfaces added to this container? // are interfaces added to this container?
if( static_cast<OInterfaceContainerHelper*>((*iter).second)->getLength() ) if( static_cast<OInterfaceContainerHelper*>(rItem.second)->getLength() )
// yes, put the type in the array // yes, put the type in the array
pArray[i++] = (*iter).first; pArray[i++] = rItem.first;
++iter;
} }
if( static_cast<t_type2ptr::size_type>(i) != nSize ) { if( static_cast<t_type2ptr::size_type>(i) != nSize ) {
// may be empty container, reduce the sequence to the right size // may be empty container, reduce the sequence to the right size
...@@ -379,16 +372,8 @@ Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const ...@@ -379,16 +372,8 @@ Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const
static t_type2ptr::iterator findType(t_type2ptr *pMap, const Type & rKey ) static t_type2ptr::iterator findType(t_type2ptr *pMap, const Type & rKey )
{ {
t_type2ptr::iterator iter = pMap->begin(); return std::find_if(pMap->begin(), pMap->end(),
t_type2ptr::iterator end = pMap->end(); [&rKey](const t_type2ptr::value_type& rItem) { return rItem.first == rKey; });
while( iter != end )
{
if (iter->first == rKey)
break;
++iter;
}
return iter;
} }
OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const
...@@ -447,14 +432,10 @@ void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rE ...@@ -447,14 +432,10 @@ void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rE
ppListenerContainers.reset(new ppp[nSize]); ppListenerContainers.reset(new ppp[nSize]);
//ppListenerContainers = new (ListenerContainer*)[nSize]; //ppListenerContainers = new (ListenerContainer*)[nSize];
t_type2ptr::iterator iter = pMap->begin();
t_type2ptr::iterator end = pMap->end();
t_type2ptr::size_type i = 0; t_type2ptr::size_type i = 0;
while( iter != end ) for (const auto& rItem : *pMap)
{ {
ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>((*iter).second); ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>(rItem.second);
++iter;
} }
} }
} }
...@@ -472,13 +453,10 @@ void OMultiTypeInterfaceContainerHelper::clear() ...@@ -472,13 +453,10 @@ void OMultiTypeInterfaceContainerHelper::clear()
{ {
::osl::MutexGuard aGuard( rMutex ); ::osl::MutexGuard aGuard( rMutex );
t_type2ptr * pMap = static_cast<t_type2ptr *>(m_pMap); t_type2ptr * pMap = static_cast<t_type2ptr *>(m_pMap);
t_type2ptr::iterator iter = pMap->begin();
t_type2ptr::iterator end = pMap->end();
while( iter != end ) for (auto& rItem : *pMap)
{ {
static_cast<OInterfaceContainerHelper*>((*iter).second)->clear(); static_cast<OInterfaceContainerHelper*>(rItem.second)->clear();
++iter;
} }
} }
...@@ -488,16 +466,8 @@ typedef std::vector< std::pair < sal_Int32 , void* > > t_long2ptr; ...@@ -488,16 +466,8 @@ typedef std::vector< std::pair < sal_Int32 , void* > > t_long2ptr;
static t_long2ptr::iterator findLong(t_long2ptr *pMap, sal_Int32 nKey ) static t_long2ptr::iterator findLong(t_long2ptr *pMap, sal_Int32 nKey )
{ {
t_long2ptr::iterator iter = pMap->begin(); return std::find_if(pMap->begin(), pMap->end(),
t_long2ptr::iterator end = pMap->end(); [&nKey](const t_long2ptr::value_type& rItem) { return rItem.first == nKey; });
while( iter != end )
{
if (iter->first == nKey)
break;
++iter;
}
return iter;
} }
OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ ) OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ )
...@@ -513,14 +483,11 @@ OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt3 ...@@ -513,14 +483,11 @@ OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt3
return; return;
t_long2ptr * pMap = static_cast<t_long2ptr *>(m_pMap); t_long2ptr * pMap = static_cast<t_long2ptr *>(m_pMap);
t_long2ptr::iterator iter = pMap->begin();
t_long2ptr::iterator end = pMap->end();
while( iter != end ) for (auto& rItem : *pMap)
{ {
delete static_cast<OInterfaceContainerHelper*>((*iter).second); delete static_cast<OInterfaceContainerHelper*>(rItem.second);
(*iter).second = nullptr; rItem.second = nullptr;
++iter;
} }
delete pMap; delete pMap;
} }
...@@ -537,17 +504,13 @@ Sequence< sal_Int32 > OMultiTypeInterfaceContainerHelperInt32::getContainedTypes ...@@ -537,17 +504,13 @@ Sequence< sal_Int32 > OMultiTypeInterfaceContainerHelperInt32::getContainedTypes
css::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize ); css::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize );
sal_Int32 * pArray = aInterfaceTypes.getArray(); sal_Int32 * pArray = aInterfaceTypes.getArray();
t_long2ptr::iterator iter = pMap->begin();
t_long2ptr::iterator end = pMap->end();
sal_Int32 i = 0; sal_Int32 i = 0;
while( iter != end ) for (const auto& rItem : *pMap)
{ {
// are interfaces added to this container? // are interfaces added to this container?
if( static_cast<OInterfaceContainerHelper*>((*iter).second)->getLength() ) if( static_cast<OInterfaceContainerHelper*>(rItem.second)->getLength() )
// yes, put the type in the array // yes, put the type in the array
pArray[i++] = (*iter).first; pArray[i++] = rItem.first;
++iter;
} }
if( static_cast<t_long2ptr::size_type>(i) != nSize ) { if( static_cast<t_long2ptr::size_type>(i) != nSize ) {
// may be empty container, reduce the sequence to the right size // may be empty container, reduce the sequence to the right size
...@@ -622,14 +585,10 @@ void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject ...@@ -622,14 +585,10 @@ void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject
typedef OInterfaceContainerHelper* ppp; typedef OInterfaceContainerHelper* ppp;
ppListenerContainers.reset(new ppp[nSize]); ppListenerContainers.reset(new ppp[nSize]);
t_long2ptr::iterator iter = pMap->begin();
t_long2ptr::iterator end = pMap->end();
t_long2ptr::size_type i = 0; t_long2ptr::size_type i = 0;
while( iter != end ) for (const auto& rItem : *pMap)
{ {
ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>((*iter).second); ppListenerContainers[i++] = static_cast<OInterfaceContainerHelper*>(rItem.second);
++iter;
} }
} }
} }
...@@ -649,13 +608,10 @@ void OMultiTypeInterfaceContainerHelperInt32::clear() ...@@ -649,13 +608,10 @@ void OMultiTypeInterfaceContainerHelperInt32::clear()
if (!m_pMap) if (!m_pMap)
return; return;
t_long2ptr * pMap = static_cast<t_long2ptr *>(m_pMap); t_long2ptr * pMap = static_cast<t_long2ptr *>(m_pMap);
t_long2ptr::iterator iter = pMap->begin();
t_long2ptr::iterator end = pMap->end();
while( iter != end ) for (auto& rItem : *pMap)
{ {
static_cast<OInterfaceContainerHelper*>((*iter).second)->clear(); static_cast<OInterfaceContainerHelper*>(rItem.second)->clear();
++iter;
} }
} }
......
...@@ -291,11 +291,10 @@ css::uno::Sequence< css::beans::Property > Info::getProperties() ...@@ -291,11 +291,10 @@ css::uno::Sequence< css::beans::Property > Info::getProperties()
css::uno::Sequence< css::beans::Property > s( css::uno::Sequence< css::beans::Property > s(
static_cast< sal_Int32 >(m_data->properties.size())); static_cast< sal_Int32 >(m_data->properties.size()));
sal_Int32 n = 0; sal_Int32 n = 0;
for (Data::PropertyMap::iterator i(m_data->properties.begin()); for (const auto& rEntry : m_data->properties)
i != m_data->properties.end(); ++i)
{ {
if (i->second.present) { if (rEntry.second.present) {
s[n++] = i->second.property; s[n++] = rEntry.second.property;
} }
} }
s.realloc(n); s.realloc(n);
...@@ -334,19 +333,16 @@ PropertySetMixinImpl::BoundListeners::~BoundListeners() { ...@@ -334,19 +333,16 @@ PropertySetMixinImpl::BoundListeners::~BoundListeners() {
} }
void PropertySetMixinImpl::BoundListeners::notify() const { void PropertySetMixinImpl::BoundListeners::notify() const {
for (BoundListenerBag::const_iterator i(m_impl->specificListeners.begin()); for (const auto& rxListener : m_impl->specificListeners)
i != m_impl->specificListeners.end(); ++i)
{ {
try { try {
(*i)->propertyChange(m_impl->event); rxListener->propertyChange(m_impl->event);
} catch (css::lang::DisposedException &) {} } catch (css::lang::DisposedException &) {}
} }
for (BoundListenerBag::const_iterator i( for (const auto& rxListener : m_impl->unspecificListeners)
m_impl->unspecificListeners.begin());
i != m_impl->unspecificListeners.end(); ++i)
{ {
try { try {
(*i)->propertyChange(m_impl->event); rxListener->propertyChange(m_impl->event);
} catch (css::lang::DisposedException &) {} } catch (css::lang::DisposedException &) {}
} }
} }
...@@ -898,18 +894,16 @@ void PropertySetMixinImpl::prepareSet( ...@@ -898,18 +894,16 @@ void PropertySetMixinImpl::prepareSet(
css::beans::PropertyChangeEvent event( css::beans::PropertyChangeEvent event(
static_cast< css::beans::XPropertySet * >(this), propertyName, static_cast< css::beans::XPropertySet * >(this), propertyName,
false, it->second.property.Handle, oldValue, newValue); false, it->second.property.Handle, oldValue, newValue);
for (Impl::VetoListenerBag::iterator i(specificVeto.begin()); for (auto& rxVetoListener : specificVeto)
i != specificVeto.end(); ++i)
{ {
try { try {
(*i)->vetoableChange(event); rxVetoListener->vetoableChange(event);
} catch (css::lang::DisposedException &) {} } catch (css::lang::DisposedException &) {}
} }
for (Impl::VetoListenerBag::iterator i(unspecificVeto.begin()); for (auto& rxVetoListener : unspecificVeto)
i != unspecificVeto.end(); ++i)
{ {
try { try {
(*i)->vetoableChange(event); rxVetoListener->vetoableChange(event);
} catch (css::lang::DisposedException &) {} } catch (css::lang::DisposedException &) {}
} }
} }
...@@ -934,22 +928,18 @@ void PropertySetMixinImpl::dispose() { ...@@ -934,22 +928,18 @@ void PropertySetMixinImpl::dispose() {
} }
css::lang::EventObject event( css::lang::EventObject event(
static_cast< css::beans::XPropertySet * >(this)); static_cast< css::beans::XPropertySet * >(this));
for (Impl::BoundListenerMap::iterator i(boundListeners.begin()); for (auto& rEntry : boundListeners)
i != boundListeners.end(); ++i)
{ {
for (BoundListenerBag::iterator j(i->second.begin()); for (auto& rxBoundListener : rEntry.second)
j != i->second.end(); ++j)
{ {
(*j)->disposing(event); rxBoundListener->disposing(event);
} }
} }
for (Impl::VetoListenerMap::iterator i(vetoListeners.begin()); for (auto& rEntry : vetoListeners)
i != vetoListeners.end(); ++i)
{ {
for (Impl::VetoListenerBag::iterator j(i->second.begin()); for (auto& rxVetoListener : rEntry.second)
j != i->second.end(); ++j)
{ {
(*j)->disposing(event); rxVetoListener->disposing(event);
} }
} }
} }
......
...@@ -494,14 +494,10 @@ InstantiatedPolymorphicStructTypeDescription::getMemberTypes() ...@@ -494,14 +494,10 @@ InstantiatedPolymorphicStructTypeDescription::getMemberTypes()
for (sal_Int32 i = 0; i != n; ++i) { for (sal_Int32 i = 0; i != n; ++i) {
OUString type(entity_->getMembers()[i].type); OUString type(entity_->getMembers()[i].type);
if (entity_->getMembers()[i].parameterized) { if (entity_->getMembers()[i].parameterized) {
for (std::vector< OUString >::const_iterator j( auto j = std::find(entity_->getTypeParameters().begin(), entity_->getTypeParameters().end(), type);
entity_->getTypeParameters().begin()); if (j != entity_->getTypeParameters().end()) {
j != entity_->getTypeParameters().end(); ++j) type = arguments_[j - entity_->getTypeParameters().begin()];
{ goto found;
if (*j == type) {
type = arguments_[j - entity_->getTypeParameters().begin()];
goto found;
}
} }
assert(false); // this cannot happen //TODO! assert(false); // this cannot happen //TODO!
found:; found:;
...@@ -2247,14 +2243,10 @@ css::uno::Any cppuhelper::TypeManager::getEnumMember( ...@@ -2247,14 +2243,10 @@ css::uno::Any cppuhelper::TypeManager::getEnumMember(
rtl::Reference< unoidl::EnumTypeEntity > const & entity, rtl::Reference< unoidl::EnumTypeEntity > const & entity,
OUString const & member) OUString const & member)
{ {
for (std::vector< unoidl::EnumTypeEntity::Member >::const_iterator i( auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
entity->getMembers().begin()); [&member](const unoidl::EnumTypeEntity::Member& rMember) { return rMember.name == member; });
i != entity->getMembers().end(); ++i) if (i != entity->getMembers().end())
{ return css::uno::makeAny(i->value);
if (i->name == member) {
return css::uno::makeAny(i->value);
}
}
return css::uno::Any(); return css::uno::Any();
} }
...@@ -2263,16 +2255,12 @@ css::uno::Any cppuhelper::TypeManager::getConstant( ...@@ -2263,16 +2255,12 @@ css::uno::Any cppuhelper::TypeManager::getConstant(
rtl::Reference< unoidl::ConstantGroupEntity > const & entity, rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
OUString const & member) OUString const & member)
{ {
for (std::vector< unoidl::ConstantGroupEntity::Member >::const_iterator i( auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
entity->getMembers().begin()); [&member](const unoidl::ConstantGroupEntity::Member& rMember) { return rMember.name == member; });
i != entity->getMembers().end(); ++i) if (i != entity->getMembers().end())
{ return css::uno::makeAny<
if (i->name == member) { css::uno::Reference< css::reflection::XTypeDescription > >(
return css::uno::makeAny< new ConstantDescription(constantGroupName, *i));
css::uno::Reference< css::reflection::XTypeDescription > >(
new ConstantDescription(constantGroupName, *i));
}
}
return css::uno::Any(); return css::uno::Any();
} }
......
...@@ -183,14 +183,14 @@ void SAL_CALL OWeakConnectionPoint::removeReference(const Reference< XReference ...@@ -183,14 +183,14 @@ void SAL_CALL OWeakConnectionPoint::removeReference(const Reference< XReference
// Search from end because the thing that last added a ref is most likely to be the // Search from end because the thing that last added a ref is most likely to be the
// first to remove a ref. // first to remove a ref.
// It's not really valid to compare the pointer directly, but it's faster. // It's not really valid to compare the pointer directly, but it's faster.
for (auto it = m_aReferences.rbegin(); it != m_aReferences.rend(); ++it) { auto it = std::find_if(m_aReferences.rbegin(), m_aReferences.rend(),
if (it->get() == rRef.get()) { [&rRef](const Reference<XReference>& rxRef) { return rxRef.get() == rRef.get(); });
m_aReferences.erase( it.base()-1 ); if (it != m_aReferences.rend()) {
return; m_aReferences.erase( it.base()-1 );
} return;
} }
// interface not found, use the correct compare method // interface not found, use the correct compare method
auto it = std::find(m_aReferences.rbegin(), m_aReferences.rend(), rRef); it = std::find(m_aReferences.rbegin(), m_aReferences.rend(), rRef);
if ( it != m_aReferences.rend() ) if ( it != m_aReferences.rend() )
m_aReferences.erase( it.base()-1 ); m_aReferences.erase( it.base()-1 );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment