[Libreoffice-commits] core.git: UnoControls/inc UnoControls/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 21 11:39:48 UTC 2021


 UnoControls/inc/basecontainercontrol.hxx         |    2 -
 UnoControls/source/base/basecontainercontrol.cxx |   31 +++++++++--------------
 2 files changed, 14 insertions(+), 19 deletions(-)

New commits:
commit 159b8fb14f3577812819508f4160c37414cce6da
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 21 09:49:37 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 21 13:39:14 2021 +0200

    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 at collabora.co.uk>

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


More information about the Libreoffice-commits mailing list