include/rtl/string.hxx |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 1959d451da06f501dd3446ebfe9c631b5400af26
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Sun May 29 16:51:55 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sun May 29 18:38:44 2022 +0200

    Improve some operator== involving OString,
    
    avoiding creation of temporary OString instances
    
    Change-Id: I27b4cb59b48b3ba40311a1f935a20250c8317d00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135093
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index e99581cd6f94..0e3dad6926e8 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1180,25 +1180,37 @@ public:
     template< typename T >
     friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type 
operator==( const OString& rStr1, const T& value )
     {
-        return rStr1.compareTo( value ) == 0;
+        return
+            rtl_str_compare_WithLength(
+                rStr1.getStr(), rStr1.getLength(), value, 
rtl_str_getLength(value))
+            == 0;
     }
 
     template< typename T >
     friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool 
>::Type operator==( const OString& rStr1, T& value )
     {
-        return rStr1.compareTo( value ) == 0;
+        return
+            rtl_str_compare_WithLength(
+                rStr1.getStr(), rStr1.getLength(), value, 
rtl_str_getLength(value))
+            == 0;
     }
 
     template< typename T >
     friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type 
operator==( const T& value, const OString& rStr2 )
     {
-        return rStr2.compareTo( value ) == 0;
+        return
+            rtl_str_compare_WithLength(
+                value, rtl_str_getLength(value), rStr2.getStr(), 
rStr2.getLength())
+            == 0;
     }
 
     template< typename T >
     friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool 
>::Type operator==( T& value, const OString& rStr2 )
     {
-        return rStr2.compareTo( value ) == 0;
+        return
+            rtl_str_compare_WithLength(
+                value, rtl_str_getLength(value), rStr2.getStr(), 
rStr2.getLength())
+            == 0;
     }
 
     /**

Reply via email to