diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-21 09:49:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-21 13:39:14 +0200 |
commit | 159b8fb14f3577812819508f4160c37414cce6da (patch) | |
tree | 5a8b2b5d2a793b9fed4ba436bfb2b134fb2692d0 | |
parent | 9230c189ebc5bcfd6303bfa7eebcd35488037d00 (diff) |
flatten vector in BaseContainerControl
no need to allocate the entries separately
Change-Id: I00c4abe75701685689eb7d09a97c349cb0271f1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119304
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | UnoControls/inc/basecontainercontrol.hxx | 2 | ||||
-rw-r--r-- | UnoControls/source/base/basecontainercontrol.cxx | 31 |
2 files changed, 14 insertions, 19 deletions
diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx index 56e2f9373af3..fe0d87f2d8cb 100644 --- a/UnoControls/inc/basecontainercontrol.hxx +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -142,7 +142,7 @@ protected: private: // list of pointer of "struct IMPL_ControlInfo" to hold child-controls - ::std::vector< std::unique_ptr<IMPL_ControlInfo> > maControlInfoList; + ::std::vector< IMPL_ControlInfo > maControlInfoList; ::cppu::OMultiTypeInterfaceContainerHelper m_aListeners; diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index 2f21979cc644..dbcfb77bbc2e 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -195,27 +195,27 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re return; // take memory for new item - IMPL_ControlInfo* pNewControl = new IMPL_ControlInfo; + IMPL_ControlInfo aNewControl; // Ready for multithreading MutexGuard aGuard (m_aMutex); // set control - pNewControl->sName = rName; - pNewControl->xControl = rControl; + aNewControl.sName = rName; + aNewControl.xControl = rControl; // and insert in list - maControlInfoList.emplace_back( pNewControl ); + maControlInfoList.emplace_back( aNewControl ); // initialize new control - pNewControl->xControl->setContext ( static_cast<OWeakObject*>(this) ); - pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ); + aNewControl.xControl->setContext ( static_cast<OWeakObject*>(this) ); + aNewControl.xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ); // when container has a peer... if (getPeer().is()) { // ... then create a peer on child - pNewControl->xControl->createPeer ( getPeer()->getToolkit(), getPeer() ); + aNewControl.xControl->createPeer ( getPeer()->getToolkit(), getPeer() ); } // Send message to all listener @@ -255,7 +255,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > for ( size_t n = 0; n < nControls; n++ ) { // Search for right control - IMPL_ControlInfo* pControl = maControlInfoList[ n ].get(); + IMPL_ControlInfo* pControl = &maControlInfoList[ n ]; if ( rControl == pControl->xControl ) { //.is it found ... remove listener from control @@ -308,18 +308,14 @@ Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString // Ready for multithreading MutexGuard aGuard ( Mutex::getGlobalMutex() ); - size_t nControls = maControlInfoList.size(); - // Search for right control - for( size_t nCount = 0; nCount < nControls; ++nCount ) + for( IMPL_ControlInfo& rSearchControl : maControlInfoList ) { - IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ].get(); - - if ( pSearchControl->sName == rName ) + if ( rSearchControl.sName == rName ) { // We have found it ... // Break operation and return. - return pSearchControl->xControl; + return rSearchControl.xControl; } } @@ -340,10 +336,9 @@ Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () Reference< XControl > * pDestination = aDescriptor.getArray (); // Copy controls to sequence - for( nCount = 0; nCount < nControls; ++nCount ) + for( IMPL_ControlInfo& rCopyControl : maControlInfoList ) { - IMPL_ControlInfo* pCopyControl = maControlInfoList[ nCount ].get(); - pDestination [ nCount ] = pCopyControl->xControl; + pDestination [ nCount++ ] = rCopyControl.xControl; } // Return sequence |