[Libreoffice-commits] core.git: vcl/qa vcl/source vcl/unx

Takeshi Abe tabe at fixedpoint.jp
Thu May 7 07:05:43 PDT 2015


 vcl/qa/cppunit/canvasbitmaptest.cxx      |    3 ++-
 vcl/source/app/IconThemeInfo.cxx         |    9 +--------
 vcl/source/app/IconThemeSelector.cxx     |    5 ++---
 vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx |    6 +++---
 4 files changed, 8 insertions(+), 15 deletions(-)

New commits:
commit 6a26624d8ba9d37481e75f5c952dff9c6dd86fb6
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Fri May 1 23:07:32 2015 +0900

    vcl: simplify code by using std::any_of/std::none_of
    
    Change-Id: I37c4fd80780738b823c7928f22deaff0ea1c6bff
    Reviewed-on: https://gerrit.libreoffice.org/15585
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index a69460b..07f2a51 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -41,6 +41,7 @@
 #include "vcl/bitmapex.hxx"
 
 #include "canvasbitmap.hxx"
+#include <algorithm>
 
 using namespace ::com::sun::star;
 using namespace vcl::unotools;
@@ -152,7 +153,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
                             aRes.first == pRGBEnd);
 
     CPPUNIT_ASSERT_MESSAGE( "rgb colors are not within [0,1] range",
-                            std::find_if(pRGBStart,pRGBEnd,&rangeCheck) == pRGBEnd);
+                            std::none_of(pRGBStart,pRGBEnd,&rangeCheck));
 
     CPPUNIT_ASSERT_MESSAGE( "First pixel is not white",
                             pRGBStart[0].Red == 1.0 && pRGBStart[0].Green == 1.0 && pRGBStart[0].Blue == 1.0);
diff --git a/vcl/source/app/IconThemeInfo.cxx b/vcl/source/app/IconThemeInfo.cxx
index 88d517c..869eb85 100644
--- a/vcl/source/app/IconThemeInfo.cxx
+++ b/vcl/source/app/IconThemeInfo.cxx
@@ -155,14 +155,7 @@ IconThemeInfo::FindIconThemeById(const std::vector<vcl::IconThemeInfo>& themes,
 /*static*/ bool
 IconThemeInfo::IconThemeIsInVector(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId)
 {
-    std::vector<vcl::IconThemeInfo>::const_iterator it = std::find_if(themes.begin(), themes.end(),
-               SameTheme(themeId));
-    if (it != themes.end()) {
-        return true;
-    }
-    else {
-        return false;
-    }
+    return std::any_of(themes.begin(), themes.end(), SameTheme(themeId));
 }
 
 } // end namespace vcl
diff --git a/vcl/source/app/IconThemeSelector.cxx b/vcl/source/app/IconThemeSelector.cxx
index b9beee3..f7971dd 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -40,9 +40,8 @@ namespace {
 bool icon_theme_is_in_installed_themes(const OUString& theme,
         const std::vector<IconThemeInfo>& installedThemes)
 {
-    return std::find_if(installedThemes.begin(), installedThemes.end(),
-               SameTheme(theme)
-           ) != installedThemes.end();
+    return std::any_of(installedThemes.begin(), installedThemes.end(),
+                       SameTheme(theme));
 }
 
 } // end anonymous namespace
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index aef326c..d47e35d 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -459,7 +459,7 @@ namespace {
             else
                 // a filter group -> search the sub filters
                 bMatch =
-                    _rEntry.endSubFilters() != ::std::find_if(
+                    ::std::any_of(
                         _rEntry.beginSubFilters(),
                         _rEntry.endSubFilters(),
                         *this
@@ -481,7 +481,7 @@ bool SalGtkFilePicker::FilterNameExists( const OUString& rTitle )
 
     if( m_pFilterList )
         bRet =
-            m_pFilterList->end() != ::std::find_if(
+            ::std::any_of(
                 m_pFilterList->begin(),
                 m_pFilterList->end(),
                 FilterTitleMatch( rTitle )
@@ -499,7 +499,7 @@ bool SalGtkFilePicker::FilterNameExists( const UnoFilterList& _rGroupedFilters )
         const UnoFilterEntry* pStart = _rGroupedFilters.getConstArray();
         const UnoFilterEntry* pEnd = pStart + _rGroupedFilters.getLength();
         for( ; pStart != pEnd; ++pStart )
-            if( m_pFilterList->end() != ::std::find_if(
+            if( ::std::any_of(
                         m_pFilterList->begin(),
                         m_pFilterList->end(),
                         FilterTitleMatch( pStart->First ) ) )


More information about the Libreoffice-commits mailing list