From 207d8b88ecf43a945745194dc999348e570a5264 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 Oct 2018 14:27:32 +0200 Subject: loplugin:useuniqueptr in ContentImplHelper Change-Id: I56909fcaf8088a353bbd0bb783c88d51b9f0822f Reviewed-on: https://gerrit.libreoffice.org/62654 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ucbhelper/source/provider/contenthelper.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'ucbhelper') diff --git a/ucbhelper/source/provider/contenthelper.cxx b/ucbhelper/source/provider/contenthelper.cxx index 4119d91690e5..1482c036b2f1 100644 --- a/ucbhelper/source/provider/contenthelper.cxx +++ b/ucbhelper/source/provider/contenthelper.cxx @@ -87,7 +87,7 @@ struct hashPtr typedef std::unordered_map < XPropertiesChangeListenerPtr, - PropertyEventSequence*, + PropertyEventSequence, hashPtr, equalPtr > @@ -696,11 +696,10 @@ void ContentImplHelper::notifyPropertiesChange( if ( it == aListeners.end() ) { // Not in map - create and insert new entry. - p = new PropertyEventSequence( nCount ); - aListeners[ pListener ] = p; + p = &aListeners.emplace( pListener, PropertyEventSequence(nCount)).first->second; } else - p = (*it).second; + p = &it->second; if ( p ) p->append( rEvent ); @@ -714,15 +713,13 @@ void ContentImplHelper::notifyPropertiesChange( { beans::XPropertiesChangeListener* pListener = static_cast< beans::XPropertiesChangeListener * >( (*it).first ); - PropertyEventSequence* pSeq = (*it).second; + PropertyEventSequence pSeq = std::move(it->second); // Remove current element. aListeners.erase( it ); // Propagate event. - pListener->propertiesChange( pSeq->getEvents() ); - - delete pSeq; + pListener->propertiesChange( pSeq.getEvents() ); it = aListeners.begin(); } -- cgit