From a10a621b48a30904b970ce01cc0bf2aa15cea9cb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 29 May 2014 07:54:23 +0200 Subject: simplify SfxListener::EndListening and StartListening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No-one is using the return values, so we can simplify the methods Change-Id: Icc2dbfb797bcd82afcbf42ed3bdc20b0426ccba1 Reviewed-on: https://gerrit.libreoffice.org/9542 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- svl/source/notify/lstner.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'svl/source/notify') diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx index 606b9a609c10..331f60017b9b 100644 --- a/svl/source/notify/lstner.cxx +++ b/svl/source/notify/lstner.cxx @@ -65,7 +65,7 @@ void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBroadcaster ) // registers a specific SfxBroadcaster -bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups ) +void SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups ) { if ( !bPreventDups || !IsListening( rBroadcaster ) ) { @@ -73,27 +73,25 @@ bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDup aBCs.push_back( &rBroadcaster ); DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" ); - return true; } - - return false; } // unregisters a specific SfxBroadcaster -bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups ) +void SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups ) { - if ( !IsListening( rBroadcaster ) ) - return false; - do { + SfxBroadcasterArr_Impl::iterator it = std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ); + if ( it == aBCs.end() ) + { + break; + } rBroadcaster.RemoveListener(*this); - aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) ); + aBCs.erase( it ); } - while ( bAllDups && IsListening( rBroadcaster ) ); - return true; + while ( bAllDups ); } -- cgit