[Lldb-commits] [lldb] r312457 - [UUID] Reimplement comparison operators more canonically. NFCI.

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 3 13:53:24 PDT 2017


Author: davide
Date: Sun Sep  3 13:53:24 2017
New Revision: 312457

URL: http://llvm.org/viewvc/llvm-project?rev=312457&view=rev
Log:
[UUID] Reimplement comparison operators more canonically. NFCI.

Modified:
    lldb/trunk/source/Utility/UUID.cpp

Modified: lldb/trunk/source/Utility/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UUID.cpp?rev=312457&r1=312456&r2=312457&view=diff
==============================================================================
--- lldb/trunk/source/Utility/UUID.cpp (original)
+++ lldb/trunk/source/Utility/UUID.cpp Sun Sep  3 13:53:24 2017
@@ -198,8 +198,7 @@ bool lldb_private::operator==(const lldb
 
 bool lldb_private::operator!=(const lldb_private::UUID &lhs,
                               const lldb_private::UUID &rhs) {
-  return ::memcmp(lhs.GetBytes(), rhs.GetBytes(),
-                  sizeof(lldb_private::UUID::ValueType)) != 0;
+  return !(lhs == rhs);
 }
 
 bool lldb_private::operator<(const lldb_private::UUID &lhs,
@@ -210,18 +209,15 @@ bool lldb_private::operator<(const lldb_
 
 bool lldb_private::operator<=(const lldb_private::UUID &lhs,
                               const lldb_private::UUID &rhs) {
-  return ::memcmp(lhs.GetBytes(), rhs.GetBytes(),
-                  sizeof(lldb_private::UUID::ValueType)) <= 0;
+  return !(lhs > rhs);
 }
 
 bool lldb_private::operator>(const lldb_private::UUID &lhs,
                              const lldb_private::UUID &rhs) {
-  return ::memcmp(lhs.GetBytes(), rhs.GetBytes(),
-                  sizeof(lldb_private::UUID::ValueType)) > 0;
+  return rhs < lhs;
 }
 
 bool lldb_private::operator>=(const lldb_private::UUID &lhs,
                               const lldb_private::UUID &rhs) {
-  return ::memcmp(lhs.GetBytes(), rhs.GetBytes(),
-                  sizeof(lldb_private::UUID::ValueType)) >= 0;
+  return !(lhs < rhs);
 }




More information about the lldb-commits mailing list