include/tools/globname.hxx | 11 ++++++----- tools/source/ref/globname.cxx | 21 --------------------- 2 files changed, 6 insertions(+), 26 deletions(-)
New commits: commit fbefacef9e136d434d5dc788d4e918bb6e3815f4 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Dec 12 09:37:32 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Dec 12 10:39:41 2023 +0100 Simplify and fix SvGlobalName comparison Its operator< (required for stl containers) was not comparing Data4. The defaulted comparison uses a different order, but that shouldn't matter. Change-Id: Id9b9d782b393866100c3e994a3902e7ce9a2676f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160607 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/tools/globname.hxx b/include/tools/globname.hxx index d72b6bf1ab51..7812a83f5735 100644 --- a/include/tools/globname.hxx +++ b/include/tools/globname.hxx @@ -22,12 +22,16 @@ #include <tools/toolsdllapi.h> #include <com/sun/star/uno/Sequence.hxx> +#include <compare> + struct SAL_WARN_UNUSED SvGUID { sal_uInt32 Data1; sal_uInt16 Data2; sal_uInt16 Data3; sal_uInt8 Data4[8]; + friend constexpr auto operator<=>(const SvGUID&, const SvGUID&) = default; + friend constexpr bool operator==(const SvGUID&, const SvGUID&) = default; }; class SvStream; @@ -52,11 +56,8 @@ public: TOOLS_DLLPUBLIC friend SvStream & operator >> ( SvStream &, SvGlobalName & ); TOOLS_DLLPUBLIC friend SvStream & WriteSvGlobalName( SvStream &, const SvGlobalName & ); - bool operator < ( const SvGlobalName & rObj ) const; - - bool operator == ( const SvGlobalName & rObj ) const; - bool operator != ( const SvGlobalName & rObj ) const - { return !(*this == rObj); } + friend constexpr auto operator<=>(const SvGlobalName&, const SvGlobalName&) = default; + friend constexpr bool operator==(const SvGlobalName&, const SvGlobalName&) = default; void MakeFromMemory( void const * pData ); bool MakeId( std::u16string_view rId ); diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx index e5cee830df22..4ae220659e3c 100644 --- a/tools/source/ref/globname.cxx +++ b/tools/source/ref/globname.cxx @@ -59,27 +59,6 @@ SvStream& operator >> ( SvStream& rStr, SvGlobalName & rObj ) return rStr; } - -bool SvGlobalName::operator < ( const SvGlobalName & rObj ) const -{ - if( m_aData.Data3 < rObj.m_aData.Data3 ) - return true; - else if( m_aData.Data3 > rObj.m_aData.Data3 ) - return false; - - if( m_aData.Data2 < rObj.m_aData.Data2 ) - return true; - else if( m_aData.Data2 > rObj.m_aData.Data2 ) - return false; - - return m_aData.Data1 < rObj.m_aData.Data1; -} - -bool SvGlobalName::operator == ( const SvGlobalName & rObj ) const -{ - return memcmp(&m_aData, &rObj.m_aData, sizeof(m_aData)) == 0; -} - void SvGlobalName::MakeFromMemory( void const * pData ) { memcpy( &m_aData, pData, sizeof( m_aData ) );