diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2015-05-12 19:54:36 +0900 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-05-13 10:50:47 +0000 |
commit | 19ba9e08cab4ff75595f53b9689989495ff5f625 (patch) | |
tree | f57962ba2676494201a874777329ed949a3f7be8 /slideshow/source/engine | |
parent | 595a109f8f5cd19cc72e1e44f2ae111427bb4330 (diff) |
slideshow: simplify code by replacing std::find_if by std::any_of/std::none_of
Change-Id: Ib8eec5074e82127e11f4fba2c0b143ab8cef3bcc
Reviewed-on: https://gerrit.libreoffice.org/15714
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'slideshow/source/engine')
-rw-r--r-- | slideshow/source/engine/animationnodes/basecontainernode.cxx | 7 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/backgroundshape.cxx | 10 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/drawshape.cxx | 10 | ||||
-rw-r--r-- | slideshow/source/engine/slide/layermanager.cxx | 14 | ||||
-rw-r--r-- | slideshow/source/engine/tools.cxx | 14 | ||||
-rw-r--r-- | slideshow/source/engine/unoviewcontainer.cxx | 9 |
6 files changed, 23 insertions, 41 deletions
diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx index cc1eb68b530e..a3c73e8e2c23 100644 --- a/slideshow/source/engine/animationnodes/basecontainernode.cxx +++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx @@ -94,10 +94,9 @@ bool BaseContainerNode::hasPendingAnimation() const // does any of our children returns "true" on // AnimationNode::hasPendingAnimation()? // If yes, we, too, return true - VectorOfNodes::const_iterator const iEnd( maChildren.end() ); - return (std::find_if( - maChildren.begin(), iEnd, - boost::mem_fn(&AnimationNode::hasPendingAnimation) ) != iEnd); + return std::any_of( + maChildren.begin(), maChildren.end(), + boost::mem_fn(&AnimationNode::hasPendingAnimation) ); } void BaseContainerNode::appendChildNode( AnimationNodeSharedPtr const& pNode ) diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index f820a266295f..762c05c692b5 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -169,16 +169,14 @@ namespace slideshow void BackgroundShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer, bool bRedrawLayer ) { - ViewBackgroundShapeVector::iterator aEnd( maViewShapes.end() ); - // already added? - if( ::std::find_if( maViewShapes.begin(), - aEnd, - ::boost::bind<bool>( + if( ::std::any_of( maViewShapes.begin(), + maViewShapes.end(), + ::boost::bind<bool>( ::std::equal_to< ViewLayerSharedPtr >(), ::boost::bind( &ViewBackgroundShape::getViewLayer, _1 ), - ::boost::cref( rNewLayer ) ) ) != aEnd ) + ::boost::cref( rNewLayer ) ) ) ) { // yes, nothing to do return; diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 7c77a3c15f2b..875dffebb58c 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -632,16 +632,14 @@ namespace slideshow void DrawShape::addViewLayer( const ViewLayerSharedPtr& rNewLayer, bool bRedrawLayer ) { - ViewShapeVector::iterator aEnd( maViewShapes.end() ); - // already added? - if( ::std::find_if( maViewShapes.begin(), - aEnd, - ::boost::bind<bool>( + if( ::std::any_of( maViewShapes.begin(), + maViewShapes.end(), + ::boost::bind<bool>( ::std::equal_to< ViewLayerSharedPtr >(), ::boost::bind( &ViewShape::getViewLayer, _1 ), - ::boost::cref( rNewLayer ) ) ) != aEnd ) + ::boost::cref( rNewLayer ) ) )) { // yes, nothing to do return; diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx index c46b90245276..7e0279920b5d 100644 --- a/slideshow/source/engine/slide/layermanager.cxx +++ b/slideshow/source/engine/slide/layermanager.cxx @@ -488,13 +488,9 @@ namespace slideshow if( mbLayerAssociationDirty || !maUpdateShapes.empty() ) return true; - const LayerVector::const_iterator aEnd( maLayers.end() ); - if( std::find_if( maLayers.begin(), - aEnd, - boost::mem_fn(&Layer::isUpdatePending)) != aEnd ) - return true; - - return false; + return std::any_of( maLayers.begin(), + maLayers.end(), + boost::mem_fn(&Layer::isUpdatePending) ); } bool LayerManager::updateSprites() @@ -552,9 +548,9 @@ namespace slideshow bRet = updateSprites(); // any non-sprite update areas left? - if( std::find_if( maLayers.begin(), + if( std::none_of( maLayers.begin(), maLayers.end(), - boost::mem_fn( &Layer::isUpdatePending )) == maLayers.end() ) + boost::mem_fn( &Layer::isUpdatePending ) ) ) return bRet; // nope, done. // update each shape on each layer, that has diff --git a/slideshow/source/engine/tools.cxx b/slideshow/source/engine/tools.cxx index 3bd58aeaf077..ca98a899fc8e 100644 --- a/slideshow/source/engine/tools.cxx +++ b/slideshow/source/engine/tools.cxx @@ -439,17 +439,9 @@ namespace slideshow const beans::NamedValue* pArray = rSequence.getConstArray(); const size_t nLen( rSequence.getLength() ); - if( nLen == 0 ) - return false; - - const beans::NamedValue* pFound = ::std::find_if( pArray, - pArray + nLen, - NamedValueComparator( rSearchKey ) ); - - if( pFound == rSequence.getConstArray() + nLen ) - return false; - - return true; + return ::std::any_of( pArray, + pArray + nLen, + NamedValueComparator( rSearchKey ) ); } basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize, diff --git a/slideshow/source/engine/unoviewcontainer.cxx b/slideshow/source/engine/unoviewcontainer.cxx index f55193886b5a..7efee4a22220 100644 --- a/slideshow/source/engine/unoviewcontainer.cxx +++ b/slideshow/source/engine/unoviewcontainer.cxx @@ -44,17 +44,16 @@ namespace slideshow bool UnoViewContainer::addView( const UnoViewSharedPtr& rView ) { // check whether same view is already added - const UnoViewVector::iterator aEnd( maViews.end() ); // already added? - if( ::std::find_if( maViews.begin(), - aEnd, - ::boost::bind( + if( ::std::any_of( maViews.begin(), + maViews.end(), + ::boost::bind( ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(), rView->getUnoView(), ::boost::bind( &UnoView::getUnoView, - _1 ) ) ) != aEnd ) + _1 ) ) ) ) { // yes, nothing to do return false; |