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 <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2022-05-29 16:51:55 +02:00
parent 3ca1a169e5
commit 1959d451da

View file

@ -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;
}
/**