Kaydet (Commit) 3ca4d116 authored tarafından Julien Nabet's avatar Julien Nabet

Replace list by vector for weakRef (sd)

Change-Id: I4c303b402e4b4d7e27cd42acf88dda90f0c8b119
Reviewed-on: https://gerrit.libreoffice.org/44643Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 582182ad
...@@ -29,22 +29,22 @@ SvUnoWeakContainer::SvUnoWeakContainer() throw() ...@@ -29,22 +29,22 @@ SvUnoWeakContainer::SvUnoWeakContainer() throw()
SvUnoWeakContainer::~SvUnoWeakContainer() throw() SvUnoWeakContainer::~SvUnoWeakContainer() throw()
{ {
for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ++it ) for (auto const& elem : maVector)
delete *it; delete elem;
maList.clear(); maVector.clear();
} }
/** inserts the given ref into this container */ /** inserts the given ref into this container */
void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xRef ) throw() void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xRef ) throw()
{ {
for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ) for ( auto it = maVector.begin(); it != maVector.end(); )
{ {
uno::WeakReference< uno::XInterface >* pRef = *it; uno::WeakReference< uno::XInterface >* pRef = *it;
uno::Reference< uno::XInterface > xTestRef( *pRef ); uno::Reference< uno::XInterface > xTestRef( *pRef );
if ( !xTestRef.is() ) if ( !xTestRef.is() )
{ {
delete pRef; delete pRef;
it = maList.erase( it ); it = maVector.erase( it );
} }
else else
{ {
...@@ -53,7 +53,7 @@ void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xR ...@@ -53,7 +53,7 @@ void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xR
++it; ++it;
} }
} }
maList.push_back( new uno::WeakReference< uno::XInterface >( xRef ) ); maVector.push_back( new uno::WeakReference< uno::XInterface >( xRef ) );
} }
/** searches the container for a ref that returns true on the given /** searches the container for a ref that returns true on the given
...@@ -65,14 +65,14 @@ bool SvUnoWeakContainer::findRef( ...@@ -65,14 +65,14 @@ bool SvUnoWeakContainer::findRef(
weakref_searchfunc pSearchFunc weakref_searchfunc pSearchFunc
) )
{ {
for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ) for ( auto it = maVector.begin(); it != maVector.end(); )
{ {
uno::WeakReference< uno::XInterface >* pRef = *it; uno::WeakReference< uno::XInterface >* pRef = *it;
uno::Reference< uno::XInterface > xTestRef( *pRef ); uno::Reference< uno::XInterface > xTestRef( *pRef );
if ( !xTestRef.is() ) if ( !xTestRef.is() )
{ {
delete pRef; delete pRef;
it = maList.erase( it ); it = maVector.erase( it );
} }
else else
{ {
...@@ -89,9 +89,9 @@ bool SvUnoWeakContainer::findRef( ...@@ -89,9 +89,9 @@ bool SvUnoWeakContainer::findRef(
void SvUnoWeakContainer::dispose() void SvUnoWeakContainer::dispose()
{ {
for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ++it ) for (auto const& elem : maVector)
{ {
uno::WeakReference< uno::XInterface >* pRef = *it; uno::WeakReference< uno::XInterface >* pRef = elem;
uno::Reference< uno::XInterface > xTestRef( *pRef ); uno::Reference< uno::XInterface > xTestRef( *pRef );
if ( xTestRef.is() ) if ( xTestRef.is() )
{ {
......
...@@ -21,16 +21,14 @@ ...@@ -21,16 +21,14 @@
#define INCLUDED_SD_SOURCE_UI_UNOIDL_UNOWCNTR_HXX #define INCLUDED_SD_SOURCE_UI_UNOIDL_UNOWCNTR_HXX
#include <cppuhelper/weakref.hxx> #include <cppuhelper/weakref.hxx>
#include <list> #include <vector>
typedef bool (*weakref_searchfunc)( const css::uno::WeakReference< css::uno::XInterface >& xRef, void const * pSearchData ); typedef bool (*weakref_searchfunc)( const css::uno::WeakReference< css::uno::XInterface >& xRef, void const * pSearchData );
typedef ::std::list< css::uno::WeakReference< css::uno::XInterface >* > WeakRefList;
class SvUnoWeakContainer class SvUnoWeakContainer
{ {
private: private:
WeakRefList maList; std::vector< css::uno::WeakReference< css::uno::XInterface >* > maVector;
public: public:
SvUnoWeakContainer() throw(); SvUnoWeakContainer() throw();
......
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