@@ -493,7 +493,7 @@ std::strong_ordering BINARY::operator<=>(const BINARY &o) const
493493 return cb < o.cb ? std::strong_ordering::less : std::strong_ordering::greater;
494494}
495495
496- int SVREID::compare (const SVREID &o) const
496+ std::strong_ordering SVREID::operator <=> (const SVREID &o) const
497497{
498498 /*
499499 * This performs a FLATUID/bytewise comparison similar to BINARY properties.
@@ -503,10 +503,10 @@ int SVREID::compare(const SVREID &o) const
503503 uint16_t o_len = cpu_to_le16 (o.pbin != nullptr ? o.pbin ->cb + 1 : 21 );
504504 uint8_t flag = pbin == nullptr ;
505505 uint8_t o_flag = o.pbin == nullptr ;
506- auto ret = memcmp (&len, &o_len, sizeof (uint16_t ));
506+ auto ret = memcmp (&len, &o_len, sizeof (uint16_t )) <=> 0 ;
507507 if (ret != 0 )
508508 return ret;
509- ret = memcmp (&flag, &o_flag, sizeof (uint8_t ));
509+ ret = memcmp (&flag, &o_flag, sizeof (uint8_t )) <=> 0 ;
510510 if (ret != 0 )
511511 return ret;
512512 uint8_t buf[20 ], o_buf[20 ];
@@ -521,19 +521,16 @@ int SVREID::compare(const SVREID &o) const
521521 cpu_to_le64p (&o_buf[8 ], o.message_id );
522522 cpu_to_le32p (&o_buf[16 ], o.instance );
523523 }
524- auto c = (flag ? bin : *pbin) <=> (o_flag ? o_bin : *o.pbin );
525- if (c == 0 )
526- return 0 ;
527- return c < 0 ? -1 : 1 ;
524+ return (flag ? bin : *pbin) <=> (o_flag ? o_bin : *o.pbin );
528525}
529526
530- int SVREID_compare (const SVREID *a, const SVREID *b)
527+ std::strong_ordering SVREID_compare (const SVREID *a, const SVREID *b)
531528{
532529 if (a == nullptr )
533- return b == nullptr ? 0 : - 1 ;
530+ return b == nullptr ? std::strong_ordering::equal : std::strong_ordering::less ;
534531 if (b == nullptr )
535- return 1 ;
536- return a-> compare (*b) ;
532+ return std::strong_ordering::greater ;
533+ return *a <=> *b ;
537534}
538535
539536template <typename T> static std::strong_ordering fpcompare (T x, T y)
@@ -611,8 +608,10 @@ int propval_compare(const void *pvalue1, const void *pvalue2, proptype_t proptyp
611608 auto c = *static_cast <const BINARY *>(pvalue1) <=> *static_cast <const BINARY *>(pvalue2);
612609 return c == 0 ? 0 : c < 0 ? -1 : 1 ;
613610 }
614- case PT_SVREID:
615- return static_cast <const SVREID *>(pvalue1)->compare (*static_cast <const SVREID *>(pvalue2));
611+ case PT_SVREID: {
612+ auto c = *static_cast <const SVREID *>(pvalue1) <=> *static_cast <const SVREID *>(pvalue2);
613+ return c == 0 ? 0 : c < 0 ? -1 : 1 ;
614+ }
616615 case PT_MV_SHORT: {
617616 auto a = static_cast <const SHORT_ARRAY *>(pvalue1);
618617 auto b = static_cast <const SHORT_ARRAY *>(pvalue2);
0 commit comments