[Libreoffice-commits] core.git: compilerplugins/clang cui/source dbaccess/source forms/source libreofficekit/qa svx/source xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Sep 8 12:46:28 UTC 2018


 compilerplugins/clang/implicitboolconversion.cxx         |    5 -
 cui/source/dialogs/cuicharmap.cxx                        |   42 +++------------
 dbaccess/source/core/api/SingleSelectQueryComposer.cxx   |   11 +--
 forms/source/component/ListBox.cxx                       |    5 -
 forms/source/richtext/richtextengine.cxx                 |    4 -
 libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx |    2 
 svx/source/dialog/charmap.cxx                            |   18 +-----
 xmloff/source/forms/formcellbinding.cxx                  |   10 ---
 8 files changed, 26 insertions(+), 71 deletions(-)

New commits:
commit 97b6fd8e9ec4c655a5b73cbb4f64be06e7057242
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Sep 8 09:50:18 2018 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 8 14:46:08 2018 +0200

    Replace find_if with proper quantifier algorithms
    
    Missed in 085269d25a705b656436feac47149296b4b4b35d
    
    Change-Id: I3cfab57232908b48d090658e0fbc948d62b3fc6f
    Reviewed-on: https://gerrit.libreoffice.org/60180
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index 4afc4ad0b92a..cf40338a4ce3 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -880,10 +880,9 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
         && !calls.empty())
     {
         CallExpr const * call = calls.top();
-        if (std::find_if(
+        if (std::any_of(
                 call->arg_begin(), call->arg_end(),
-                [expr](Expr const * e) { return expr == e->IgnoreParens(); })
-            != call->arg_end())
+                [expr](Expr const * e) { return expr == e->IgnoreParens(); }))
         {
             report(
                 DiagnosticsEngine::Warning,
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 06169a053109..a0a4455669ed 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -284,13 +284,9 @@ void SvxCharacterMap::updateRecentCharControl()
 
 void SvxCharacterMap::updateRecentCharacterList(const OUString& sTitle, const OUString& rFont)
 {
-    auto itChar = std::find_if(maRecentCharList.begin(),
-         maRecentCharList.end(),
-         [sTitle] (const OUString & a) { return a == sTitle; });
+    auto itChar = std::find(maRecentCharList.begin(), maRecentCharList.end(), sTitle);
 
-    auto itChar2 = std::find_if(maRecentCharFontList.begin(),
-         maRecentCharFontList.end(),
-         [rFont] (const OUString & a) { return a == rFont; });
+    auto itChar2 = std::find(maRecentCharFontList.begin(), maRecentCharFontList.end(), rFont);
 
     // if recent char to be added is already in list, remove it
     if( itChar != maRecentCharList.end() &&  itChar2 != maRecentCharFontList.end() )
@@ -328,13 +324,9 @@ void SvxCharacterMap::updateRecentCharacterList(const OUString& sTitle, const OU
 
 void SvxCharacterMap::updateFavCharacterList(const OUString& sTitle, const OUString& rFont)
 {
-    auto itChar = std::find_if(maFavCharList.begin(),
-         maFavCharList.end(),
-         [sTitle] (const OUString & a) { return a == sTitle; });
+    auto itChar = std::find(maFavCharList.begin(), maFavCharList.end(), sTitle);
 
-    auto itChar2 = std::find_if(maFavCharFontList.begin(),
-         maFavCharFontList.end(),
-         [rFont] (const OUString & a) { return a == rFont; });
+    auto itChar2 = std::find(maFavCharFontList.begin(), maFavCharFontList.end(), rFont);
 
     // if Fav char to be added is already in list, remove it
     if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
@@ -393,13 +385,9 @@ void SvxCharacterMap::updateFavCharControl()
 
 void SvxCharacterMap::deleteFavCharacterFromList(const OUString& sTitle, const OUString& rFont)
 {
-    auto itChar = std::find_if(maFavCharList.begin(),
-         maFavCharList.end(),
-         [sTitle] (const OUString & a) { return a == sTitle; });
+    auto itChar = std::find(maFavCharList.begin(), maFavCharList.end(), sTitle);
 
-    auto itChar2 = std::find_if(maFavCharFontList.begin(),
-         maFavCharFontList.end(),
-         [rFont] (const OUString & a) { return a == rFont; });
+    auto itChar2 = std::find(maFavCharFontList.begin(), maFavCharFontList.end(), rFont);
 
     // if Fav char to be added is already in list, remove it
     if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
@@ -543,19 +531,16 @@ void SvxCharacterMap::init()
 
 bool SvxCharacterMap::isFavChar(const OUString& sTitle, const OUString& rFont)
 {
-    auto itChar = std::find_if(maFavCharList.begin(),
+    auto isFavCharTitleExists = std::any_of(maFavCharList.begin(),
          maFavCharList.end(),
          [sTitle] (const OUString & a) { return a == sTitle; });
 
-    auto itChar2 = std::find_if(maFavCharFontList.begin(),
+    auto isFavCharFontExists = std::any_of(maFavCharFontList.begin(),
          maFavCharFontList.end(),
          [rFont] (const OUString & a) { return a == rFont; });
 
     // if Fav char to be added is already in list, remove it
-    if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
-        return true;
-    else
-        return false;
+    return isFavCharTitleExists && isFavCharFontExists;
 }
 
 
@@ -763,15 +748,10 @@ IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, weld::ComboBoxText&, void)
 IMPL_LINK(SvxCharacterMap, RecentClearClickHdl, SvxCharView*, rView, void)
 {
     OUString sTitle = rView->GetText();
-    auto itChar = std::find_if(maRecentCharList.begin(),
-         maRecentCharList.end(),
-         [sTitle] (const OUString & a) { return a == sTitle; });
+    auto itChar = std::find(maRecentCharList.begin(), maRecentCharList.end(), sTitle);
 
     OUString sFont = rView->GetFont().GetFamilyName();
-    auto itChar2 = std::find_if(maRecentCharFontList.begin(),
-         maRecentCharFontList.end(),
-         [sFont] (const OUString & a)
-         { return a == sFont; });
+    auto itChar2 = std::find(maRecentCharFontList.begin(), maRecentCharFontList.end(), sFont);
 
     // if recent char to be added is already in list, remove it
     if( itChar != maRecentCharList.end() &&  itChar2 != maRecentCharFontList.end() )
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 5a0bead4c8be..4892df42be23 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -891,20 +891,15 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns(  )
 
                 OUString sRealName;
                 xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
-                std::vector< OUString>::const_iterator aFindName;
                 if ( sColumnName.isEmpty() )
                     xProp->getPropertyValue(PROPERTY_NAME) >>= sColumnName;
 
-                aFindName = std::find_if(aNames.begin(),aNames.end(),
-                                    [&aCaseCompare, &sColumnName](const OUString& lhs)
-                                    { return aCaseCompare(lhs, sColumnName); } );
                 sal_Int32 j = 0;
-                while ( aFindName != aNames.end() )
+                while ( std::any_of(aNames.begin(),aNames.end(),
+                                    [&aCaseCompare, &sColumnName](const OUString& lhs)
+                                    { return aCaseCompare(lhs, sColumnName); } ) )
                 {
                     sColumnName += OUString::number(++j);
-                    aFindName = std::find_if(aNames.begin(),aNames.end(),
-                                        [&aCaseCompare, &sColumnName](const OUString& lhs)
-                                        { return aCaseCompare(lhs, sColumnName); } );
                 }
 
                 pColumn->setName(sColumnName);
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 6f36ab12bf17..f294615cdd97 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -463,9 +463,8 @@ namespace frm
         // #i27024#
         const Any* pSelectSequenceValue = nullptr;
 
-        const OUString* pSelectedItemsPos = ::std::find_if(
-            _rPropertyNames.begin(), _rPropertyNames.end(),
-             [](OUString const & s) { return s == PROPERTY_SELECT_SEQ; }
+        const OUString* pSelectedItemsPos = std::find(
+            _rPropertyNames.begin(), _rPropertyNames.end(), PROPERTY_SELECT_SEQ
         );
         auto aStringItemListExists = std::any_of(
             _rPropertyNames.begin(), _rPropertyNames.end(),
diff --git a/forms/source/richtext/richtextengine.cxx b/forms/source/richtext/richtextengine.cxx
index 63a055a3a301..481c80ba4e91 100644
--- a/forms/source/richtext/richtextengine.cxx
+++ b/forms/source/richtext/richtextengine.cxx
@@ -115,10 +115,10 @@ namespace frm
 
     void RichTextEngine::revokeEngineStatusListener( IEngineStatusListener const * _pListener )
     {
-        ::std::vector< IEngineStatusListener* >::iterator aPos = ::std::find_if(
+        ::std::vector< IEngineStatusListener* >::iterator aPos = ::std::find(
             m_aStatusListeners.begin(),
             m_aStatusListeners.end(),
-            [_pListener](IEngineStatusListener * p) { return p == _pListener; }
+            _pListener
         );
         OSL_ENSURE( aPos != m_aStatusListeners.end(), "RichTextEngine::revokeEngineStatusListener: listener not registered!" );
         if ( aPos != m_aStatusListeners.end() )
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index 32ba8115a4aa..82c4a9de4b0c 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -213,7 +213,7 @@ void recentUnoChanged( GtkWidget* pSelector, gpointer /* pItem */ )
 static void addToRecentUnoCommands(GtvApplicationWindow* pWindow, const std::string& rUnoCmd, std::string rArgs)
 {
     GtvMainToolbar* pToolbar = gtv_application_window_get_main_toolbar(pWindow);
-    rArgs.erase(std::find_if(rArgs.begin(), rArgs.end(), [](char ch) { return ch == '\n'; }));
+    rArgs.erase(std::find(rArgs.begin(), rArgs.end(), '\n'));
     const std::string rUnoCmdStr = rUnoCmd + " | " + rArgs;
 
 
diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index 0d28ecf57e1c..aa36c3198926 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -276,13 +276,8 @@ void SvxShowCharSet::updateFavCharacterList(const OUString& sTitle, const OUStri
 {
     if(isFavChar(sTitle, rFont))
     {
-        auto itChar = std::find_if(maFavCharList.begin(),
-             maFavCharList.end(),
-             [sTitle] (const OUString & a) { return a == sTitle; });
-
-        auto itChar2 = std::find_if(maFavCharFontList.begin(),
-             maFavCharFontList.end(),
-             [rFont] (const OUString & a) { return a == rFont; });
+        auto itChar = std::find(maFavCharList.begin(), maFavCharList.end(), sTitle);
+        auto itChar2 = std::find(maFavCharFontList.begin(), maFavCharFontList.end(), rFont);
 
         // if Fav char to be added is already in list, remove it
         if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
@@ -307,13 +302,8 @@ void SvxShowCharSet::updateFavCharacterList(const OUString& sTitle, const OUStri
         return;
     }
 
-    auto itChar = std::find_if(maFavCharList.begin(),
-         maFavCharList.end(),
-         [sTitle] (const OUString & a) { return a == sTitle; });
-
-    auto itChar2 = std::find_if(maFavCharFontList.begin(),
-         maFavCharFontList.end(),
-         [rFont] (const OUString & a) { return a == rFont; });
+    auto itChar = std::find(maFavCharList.begin(), maFavCharList.end(), sTitle);
+    auto itChar2 = std::find(maFavCharFontList.begin(), maFavCharFontList.end(), rFont);
 
     // if Fav char to be added is already in list, remove it
     if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
diff --git a/xmloff/source/forms/formcellbinding.cxx b/xmloff/source/forms/formcellbinding.cxx
index 1340901ea420..a982c75cd438 100644
--- a/xmloff/source/forms/formcellbinding.cxx
+++ b/xmloff/source/forms/formcellbinding.cxx
@@ -251,15 +251,7 @@ bool FormCellBindingHelper::isSpreadsheetDocumentWhichSupplies( const Reference<
             if ( xDocumentFactory.is() )
                 aAvailableServices = xDocumentFactory->getAvailableServiceNames( );
 
-            const OUString* pFound = ::std::find_if(
-                aAvailableServices.begin(),
-                aAvailableServices.end(),
-                StringCompare( _rService )
-            );
-            if ( pFound - aAvailableServices.getConstArray() < aAvailableServices.getLength() )
-            {
-                bYesItIs = true;
-            }
+            bYesItIs = std::any_of( aAvailableServices.begin(), aAvailableServices.end(), StringCompare( _rService ) );
         }
     }
     catch( const Exception& )


More information about the Libreoffice-commits mailing list