[Libreoffice-commits] core.git: basic/source compilerplugins/clang desktop/source i18nlangtag/source include/editeng sc/source sw/source vcl/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 18 09:23:33 UTC 2020


 basic/source/inc/sbunoobj.hxx                      |    4 +++-
 compilerplugins/clang/stringviewparam.cxx          |    4 ----
 desktop/source/deployment/registry/dp_registry.cxx |    3 ++-
 i18nlangtag/source/languagetag/languagetag.cxx     |    3 ++-
 include/editeng/svxacorr.hxx                       |    3 ++-
 sc/source/filter/excel/xistyle.cxx                 |    3 ++-
 sc/source/filter/inc/workbookhelper.hxx            |    4 +++-
 sc/source/filter/oox/workbookhelper.cxx            |    2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx       |    3 ++-
 sw/source/filter/ww8/ww8par.hxx                    |    3 ++-
 vcl/source/helper/driverblocklist.cxx              |    6 +++++-
 11 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 6fa1161d3113d43f38acdf9207627659fbc137c8
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Nov 18 08:46:33 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Nov 18 10:22:44 2020 +0100

    loplugin:stringviewparam: No good reason to exclude operator functions
    
    (at least not in general)
    
    Change-Id: I71337b53dc9735e90a37ee532d0a8a08797b518c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106043
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx
index e06b0e0137d2..d2458ef6b86b 100644
--- a/basic/source/inc/sbunoobj.hxx
+++ b/basic/source/inc/sbunoobj.hxx
@@ -31,6 +31,8 @@
 #include <com/sun/star/reflection/XIdlClass.hpp>
 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
 #include <rtl/ustring.hxx>
+
+#include <string_view>
 #include <unordered_map>
 #include <vector>
 #include <map>
@@ -63,7 +65,7 @@ class SbUnoStructRefObject: public SbxObject
 {
     struct caseLessComp
     {
-        bool operator() (const OUString& rProp, const OUString& rOtherProp ) const
+        bool operator() (const OUString& rProp, std::u16string_view rOtherProp ) const
         {
             return rProp.compareToIgnoreAsciiCase( rOtherProp ) < 0;
         }
diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx
index 040f8f63b502..0f5ebfc70a3b 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -435,10 +435,6 @@ private:
                 return false;
             }
         }
-        if (decl->isOverloadedOperator()) // e.g. operator()(const OUString&, const OUString&)
-        {
-            return false;
-        }
         if (decl->isFunctionTemplateSpecialization())
         {
             return false;
diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx
index 50d0c0c4d68e..90248158056a 100644
--- a/desktop/source/deployment/registry/dp_registry.cxx
+++ b/desktop/source/deployment/registry/dp_registry.cxx
@@ -44,6 +44,7 @@
 #include <com/sun/star/deployment/XPackageTypeInfo.hpp>
 #include <com/sun/star/deployment/XPackageRegistry.hpp>
 #include <set>
+#include <string_view>
 #include <unordered_map>
 #include <unordered_set>
 
@@ -69,7 +70,7 @@ class PackageRegistryImpl : private MutexHolder, public t_helper
         }
     };
     struct ci_string_equals {
-        bool operator () ( OUString const & str1, OUString const & str2 ) const{
+        bool operator () ( OUString const & str1, std::u16string_view str2 ) const{
             return str1.equalsIgnoreAsciiCase( str2 );
         }
     };
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index ab9e33019428..b9b6cc20a2d8 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -23,6 +23,7 @@
 #include <tools/long.hxx>
 #include <algorithm>
 #include <map>
+#include <string_view>
 #include <unordered_set>
 
 //#define erDEBUG
@@ -88,7 +89,7 @@ static const KnownTagSet & getKnowns()
 namespace {
 struct compareIgnoreAsciiCaseLess
 {
-    bool operator()( const OUString& r1, const OUString& r2 ) const
+    bool operator()( const OUString& r1, std::u16string_view r2 ) const
     {
         return r1.compareToIgnoreAsciiCase( r2) < 0;
     }
diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx
index 52f7bfdd5271..4e5d929405f0 100644
--- a/include/editeng/svxacorr.hxx
+++ b/include/editeng/svxacorr.hxx
@@ -31,6 +31,7 @@
 #include <optional>
 #include <map>
 #include <memory>
+#include <string_view>
 
 class CharClass;
 class SfxPoolItem;
@@ -43,7 +44,7 @@ namespace tools { template <typename T> class SvRef; }
 
 struct CompareSvStringsISortDtor
 {
-    bool operator()( OUString const& lhs, OUString const& rhs ) const
+    bool operator()( OUString const& lhs, std::u16string_view rhs ) const
     {
         return lhs.compareToIgnoreAsciiCase( rhs ) < 0;
     }
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 98c91ab6f8c2..a2d76b6e8d54 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -68,6 +68,7 @@
 #include <root.hxx>
 #include <colrowst.hxx>
 
+#include <string_view>
 #include <vector>
 
 #include <cppuhelper/implbase.hxx>
@@ -1598,7 +1599,7 @@ namespace {
 /** Functor for case-insensitive string comparison, usable in maps etc. */
 struct IgnoreCaseCompare
 {
-    bool operator()( const OUString& rName1, const OUString& rName2 ) const
+    bool operator()( const OUString& rName1, std::u16string_view rName2 ) const
         { return rName1.compareToIgnoreAsciiCase( rName2 ) < 0; }
 };
 
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index ad1018302265..0fd9ca5ebc64 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -21,6 +21,8 @@
 #define INCLUDED_SC_SOURCE_FILTER_INC_WORKBOOKHELPER_HXX
 
 #include <memory>
+#include <string_view>
+
 #include <oox/helper/storagebase.hxx>
 #include <address.hxx>
 
@@ -61,7 +63,7 @@ class ExcelFilter;
 /** Functor for case-insensitive string comparison, usable in maps etc. */
 struct IgnoreCaseCompare
 {
-    bool operator()( const OUString& rName1, const OUString& rName2 ) const;
+    bool operator()( const OUString& rName1, std::u16string_view rName2 ) const;
 };
 
 class AddressConverter;
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 32b393e52215..8214ccb0cf4e 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -94,7 +94,7 @@ using ::oox::core::FilterBase;
 using ::oox::core::FragmentHandler;
 using ::oox::core::XmlFilterBase;
 
-bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
+bool IgnoreCaseCompare::operator()( const OUString& rName1, std::u16string_view rName2 ) const
 {
     // TODO: compare with collator
     return rName1.compareToIgnoreAsciiCase(rName2 ) < 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 99cd7eabd6c4..ad61fc767b41 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -150,6 +150,7 @@
 
 #include <algorithm>
 #include <stdarg.h>
+#include <string_view>
 
 #include <toolkit/helper/vclunohelper.hxx>
 #include <unicode/regex.h>
@@ -6288,7 +6289,7 @@ namespace {
 /// Functor to do case-insensitive ordering of OUString instances.
 struct OUStringIgnoreCase
 {
-    bool operator() (const OUString& lhs, const OUString& rhs) const
+    bool operator() (const OUString& lhs, std::u16string_view rhs) const
     {
         return lhs.compareToIgnoreAsciiCase(rhs) < 0;
     }
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 3bfb20310ecd..07beb3592bff 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -30,6 +30,7 @@
 
 #include <vector>
 #include <stack>
+#include <string_view>
 #include <deque>
 #include <map>
 #include <utility>
@@ -441,7 +442,7 @@ namespace SwWW8
 {
     struct ltstr
     {
-        bool operator()(const OUString &r1, const OUString &r2) const
+        bool operator()(const OUString &r1, std::u16string_view r2) const
         {
             return r1.compareToIgnoreAsciiCase(r2)<0;
         }
diff --git a/vcl/source/helper/driverblocklist.cxx b/vcl/source/helper/driverblocklist.cxx
index a24cdc98fbcb..b946d559c760 100644
--- a/vcl/source/helper/driverblocklist.cxx
+++ b/vcl/source/helper/driverblocklist.cxx
@@ -10,6 +10,7 @@
 #include <driverblocklist.hxx>
 
 #include <algorithm>
+#include <string_view>
 
 #include <sal/log.hxx>
 
@@ -562,7 +563,10 @@ struct compareIgnoreAsciiCase
     {
     }
 
-    bool operator()(const OUString& rCompare) { return maString.equalsIgnoreAsciiCase(rCompare); }
+    bool operator()(std::u16string_view rCompare)
+    {
+        return maString.equalsIgnoreAsciiCase(rCompare);
+    }
 
 private:
     OUString maString;


More information about the Libreoffice-commits mailing list