[Libreoffice-commits] core.git: include/rtl sal/qa

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sun Dec 20 13:27:34 UTC 2020


 include/rtl/ustring.hxx                               |   86 ------------------
 sal/qa/rtl/strings/test_strings_defaultstringview.cxx |   18 +--
 2 files changed, 9 insertions(+), 95 deletions(-)

New commits:
commit 22f7411ecfe0ecc2a62bbc85a6ed27977df03e89
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sun Dec 20 10:50:26 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sun Dec 20 14:26:49 2020 +0100

    Remove the OUString vs. std::u16string_view comparison operators again
    
    ...that were introduced in e6dfaf9f44f9939abc338c83b3024108431d0f69 "Turn
    OUStringLiteral into a consteval'ed, static-refcound rtl_uString" to avoid
    ambiguities, but which is no longer an issue since
    46c5de832868d2812448b2caace3eeaa9237b9f6 "make *String(string_view) constructors
    explicit"
    
    Change-Id: I0a7a3fe23412f77fa85fb7e90f04e22f9abd9230
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108044
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 270eedd2c32d..ee3cfe170555 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1950,92 +1950,6 @@ public:
     /// @endcond
 #endif
 
-#if defined LIBO_INTERNAL_ONLY
-    friend bool operator ==(OUString const & lhs, std::u16string_view rhs) {
-        return
-            rtl_ustr_reverseCompare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size())
-            == 0;
-    }
-
-    friend bool operator !=(OUString const & lhs, std::u16string_view rhs) {
-        return
-            rtl_ustr_reverseCompare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size())
-            != 0;
-    }
-
-    friend bool operator <(OUString const & lhs, std::u16string_view rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
-            < 0;
-    }
-
-    friend bool operator <=(OUString const & lhs, std::u16string_view rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
-            <= 0;
-    }
-
-    friend bool operator >(OUString const & lhs, std::u16string_view rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
-            > 0;
-    }
-
-    friend bool operator >=(OUString const & lhs, std::u16string_view rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
-            >= 0;
-    }
-
-    friend bool operator ==(std::u16string_view lhs, OUString const & rhs) {
-        return
-            rtl_ustr_reverseCompare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length)
-            == 0;
-    }
-
-    friend bool operator !=(std::u16string_view lhs, OUString const & rhs) {
-        return
-            rtl_ustr_reverseCompare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length)
-            != 0;
-    }
-
-    friend bool operator <(std::u16string_view lhs, OUString const & rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
-            < 0;
-    }
-
-    friend bool operator <=(std::u16string_view lhs, OUString const & rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
-            <= 0;
-    }
-
-    friend bool operator >(std::u16string_view lhs, OUString const & rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
-            > 0;
-    }
-
-    friend bool operator >=(std::u16string_view lhs, OUString const & rhs) {
-        return
-            (rtl_ustr_compare_WithLength(
-                lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
-            >= 0;
-    }
-#endif
-
     /**
       Returns a hashcode for this string.
 
diff --git a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx
index a188886e5d49..591688b31c3c 100644
--- a/sal/qa/rtl/strings/test_strings_defaultstringview.cxx
+++ b/sal/qa/rtl/strings/test_strings_defaultstringview.cxx
@@ -52,19 +52,19 @@ class Test : public CppUnit::TestFixture
                              OUString("foo").startsWithIgnoreAsciiCase(std::u16string_view()));
         CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWith(std::u16string_view()));
         CPPUNIT_ASSERT_EQUAL(true, OUString("foo").endsWithIgnoreAsciiCase(std::u16string_view()));
-        OUString const foo("foo"); // avoid loplugin:stringconstant
+        OUString const foo("foo"); // avoid loplugin:stringconstant, loplugin:stringview
         CPPUNIT_ASSERT_EQUAL(false, foo == std::u16string_view());
         CPPUNIT_ASSERT_EQUAL(true, foo != std::u16string_view());
-        CPPUNIT_ASSERT_EQUAL(false, OUString("foo") < std::u16string_view());
-        CPPUNIT_ASSERT_EQUAL(false, OUString("foo") <= std::u16string_view());
-        CPPUNIT_ASSERT_EQUAL(true, OUString("foo") > std::u16string_view());
-        CPPUNIT_ASSERT_EQUAL(true, OUString("foo") >= std::u16string_view());
+        CPPUNIT_ASSERT_EQUAL(false, foo < std::u16string_view());
+        CPPUNIT_ASSERT_EQUAL(false, foo <= std::u16string_view());
+        CPPUNIT_ASSERT_EQUAL(true, foo > std::u16string_view());
+        CPPUNIT_ASSERT_EQUAL(true, foo >= std::u16string_view());
         CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() == foo);
         CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() != foo);
-        CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() < OUString("foo"));
-        CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() <= OUString("foo"));
-        CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() > OUString("foo"));
-        CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() >= OUString("foo"));
+        CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() < foo);
+        CPPUNIT_ASSERT_EQUAL(true, std::u16string_view() <= foo);
+        CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() > foo);
+        CPPUNIT_ASSERT_EQUAL(false, std::u16string_view() >= foo);
         CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").indexOf(std::u16string_view()));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").lastIndexOf(std::u16string_view()));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), OUString("foo").lastIndexOf(std::u16string_view(), 3));


More information about the Libreoffice-commits mailing list