[Libreoffice-commits] core.git: slideshow/source slideshow/test

Takeshi Abe tabe at fixedpoint.jp
Wed May 13 03:51:14 PDT 2015


 slideshow/source/engine/animationnodes/basecontainernode.cxx |    7 ++---
 slideshow/source/engine/shapes/backgroundshape.cxx           |   10 +++----
 slideshow/source/engine/shapes/drawshape.cxx                 |   10 +++----
 slideshow/source/engine/slide/layermanager.cxx               |   14 +++--------
 slideshow/source/engine/tools.cxx                            |   14 ++---------
 slideshow/source/engine/unoviewcontainer.cxx                 |    9 +++----
 slideshow/source/inc/listenercontainer.hxx                   |    8 ++----
 slideshow/test/testshape.cxx                                 |    4 +--
 8 files changed, 28 insertions(+), 48 deletions(-)

New commits:
commit 19ba9e08cab4ff75595f53b9689989495ff5f625
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue May 12 19:54:36 2015 +0900

    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 at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx
index cc1eb68..a3c73e8 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 f820a26..762c05c 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 7c77a3c..875dffe 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 c46b902..7e02799 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 3bd58ae..ca98a89 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 f551938..7efee4a 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;
diff --git a/slideshow/source/inc/listenercontainer.hxx b/slideshow/source/inc/listenercontainer.hxx
index e87a6a5..2b7ae49 100644
--- a/slideshow/source/inc/listenercontainer.hxx
+++ b/slideshow/source/inc/listenercontainer.hxx
@@ -89,13 +89,11 @@ template< typename ListenerT > struct ListenerOperations
     static bool notifySingleListener( ContainerT& rContainer,
                                       FuncT       func )
     {
-        const typename ContainerT::const_iterator aEnd( rContainer.end() );
-
         // true: a handler in this queue processed the event
         // false: no handler in this queue finally processed the event
-        return (std::find_if( rContainer.begin(),
-                              aEnd,
-                              func ) != aEnd);
+        return std::any_of( rContainer.begin(),
+                            rContainer.end(),
+                            func );
     }
 
     /// Notify all listeners
diff --git a/slideshow/test/testshape.cxx b/slideshow/test/testshape.cxx
index 687a953..46173d9 100644
--- a/slideshow/test/testshape.cxx
+++ b/slideshow/test/testshape.cxx
@@ -127,13 +127,13 @@ private:
     }
     virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer )
     {
-        if( std::find_if(
+        if( std::none_of(
                 maViewLayers.begin(),
                 maViewLayers.end(),
                 boost::bind( std::equal_to< target::ViewLayerSharedPtr >(),
                              boost::cref( rNewLayer ),
                              boost::bind( o3tl::select1st<ViewVector::value_type>(),
-                                          _1 ))) == maViewLayers.end() )
+                                          _1 ))) )
             throw std::exception();
 
         maViewLayers.erase(


More information about the Libreoffice-commits mailing list