[Libreoffice-commits] core.git: sd/source
Noel Grandin
noel.grandin at collabora.co.uk
Fri Mar 16 18:24:58 UTC 2018
sd/source/ui/unoidl/unowcntr.cxx | 24 +++++++++---------------
sd/source/ui/unoidl/unowcntr.hxx | 2 +-
2 files changed, 10 insertions(+), 16 deletions(-)
New commits:
commit 92dc87cbac74c1be260534b5e38088c44515a47b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Mar 16 14:38:30 2018 +0200
loplugin:useuniqueptr in SvUnoWeakContainer
just use a std::vector here, these are small objects, no need to
allocate them separately
Change-Id: Ie9f8df88eb7c291e2c99177d0f5e4bfc1c7ab542
Reviewed-on: https://gerrit.libreoffice.org/51415
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sd/source/ui/unoidl/unowcntr.cxx b/sd/source/ui/unoidl/unowcntr.cxx
index bb1687b07362..7583b1f569d4 100644
--- a/sd/source/ui/unoidl/unowcntr.cxx
+++ b/sd/source/ui/unoidl/unowcntr.cxx
@@ -29,9 +29,6 @@ SvUnoWeakContainer::SvUnoWeakContainer() throw()
SvUnoWeakContainer::~SvUnoWeakContainer() throw()
{
- for (auto const& elem : maVector)
- delete elem;
- maVector.clear();
}
/** inserts the given ref into this container */
@@ -39,21 +36,20 @@ void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xR
{
for ( auto it = maVector.begin(); it != maVector.end(); )
{
- uno::WeakReference< uno::XInterface >* pRef = *it;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::WeakReference< uno::XInterface > & rWeakRef = *it;
+ uno::Reference< uno::XInterface > xTestRef( rWeakRef );
if ( !xTestRef.is() )
{
- delete pRef;
it = maVector.erase( it );
}
else
{
- if ( *pRef == xRef )
+ if ( rWeakRef == xRef )
return;
++it;
}
}
- maVector.push_back( new uno::WeakReference< uno::XInterface >( xRef ) );
+ maVector.emplace_back( uno::WeakReference< uno::XInterface >( xRef ) );
}
/** searches the container for a ref that returns true on the given
@@ -67,18 +63,17 @@ bool SvUnoWeakContainer::findRef(
{
for ( auto it = maVector.begin(); it != maVector.end(); )
{
- uno::WeakReference< uno::XInterface >* pRef = *it;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::WeakReference< uno::XInterface > & itRef = *it;
+ uno::Reference< uno::XInterface > xTestRef( itRef );
if ( !xTestRef.is() )
{
- delete pRef;
it = maVector.erase( it );
}
else
{
- if( (*pSearchFunc)( *pRef, pSearchData ) )
+ if( (*pSearchFunc)( itRef, pSearchData ) )
{
- rRef = *pRef;
+ rRef = itRef;
return true;
}
++it;
@@ -91,8 +86,7 @@ void SvUnoWeakContainer::dispose()
{
for (auto const& elem : maVector)
{
- uno::WeakReference< uno::XInterface >* pRef = elem;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::Reference< uno::XInterface > xTestRef( elem );
if ( xTestRef.is() )
{
uno::Reference< lang::XComponent > xComp( xTestRef, uno::UNO_QUERY );
diff --git a/sd/source/ui/unoidl/unowcntr.hxx b/sd/source/ui/unoidl/unowcntr.hxx
index 787c81d3c3b3..8d1a5e441912 100644
--- a/sd/source/ui/unoidl/unowcntr.hxx
+++ b/sd/source/ui/unoidl/unowcntr.hxx
@@ -28,7 +28,7 @@ typedef bool (*weakref_searchfunc)( const css::uno::WeakReference< css::uno::XIn
class SvUnoWeakContainer
{
private:
- std::vector< css::uno::WeakReference< css::uno::XInterface >* > maVector;
+ std::vector< css::uno::WeakReference< css::uno::XInterface > > maVector;
public:
SvUnoWeakContainer() throw();
More information about the Libreoffice-commits
mailing list