]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados, os: drop WRITE_{EQ,CMP}_OPERATORS_3()
authorKefu Chai <tchaikov@gmail.com>
Wed, 3 Aug 2022 02:53:04 +0000 (10:53 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 4 Aug 2022 13:33:51 +0000 (21:33 +0800)
the default-generated comparison operators can fulfill our needs.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/cmp.h
src/librados/ListObjectImpl.h
src/os/filestore/SequencerPosition.h

index 442e11430ffb9214b7a5f99ddfac917a61e5672e..eb47a6259f73c58541911f1be5213ef1f8876715 100644 (file)
@@ -4,36 +4,6 @@
 /*
  * macros to define comparison operators for classes with small numbers of members.
  */
-#define WRITE_EQ_OPERATORS_3(type, a, b, c)                            \
-  inline bool operator==(const type &l, const type &r) {               \
-    return l.a == r.a && l.b == r.b && l.c == r.c;                     \
-  }                                                                    \
-  inline bool operator!=(const type &l, const type &r) {               \
-    return l.a != r.a || l.b != r.b || l.c != r.c;                     \
-  }
-
-#define WRITE_CMP_OPERATORS_3(type, a, b, c)                           \
-  inline bool operator>(const type &l, const type &r) {                        \
-    return l.a > r.a ||                                                        \
-      (l.a == r.a && (l.b > r.b ||                                     \
-                     (l.b == r.b && (l.c > r.c))));                    \
-  }                                                                    \
-  inline bool operator<(const type &l, const type &r) {                        \
-    return l.a < r.a ||                                                        \
-      (l.a == r.a && (l.b < r.b ||                                     \
-                     (l.b == r.b && (l.c < r.c))));                    \
-  }                                                                    \
-  inline bool operator>=(const type &l, const type &r) {               \
-    return l.a > r.a ||                                                        \
-      (l.a == r.a && (l.b > r.b ||                                     \
-                     (l.b == r.b && (l.c >= r.c))));                   \
-  }                                                                    \
-  inline bool operator<=(const type &l, const type &r) {               \
-    return l.a < r.a ||                                                        \
-      (l.a == r.a && (l.b < r.b ||                                     \
-                     (l.b == r.b && (l.c <= r.c))));                   \
-  }
-
 #define WRITE_EQ_OPERATORS_4(type, a, b, c, d)                         \
   inline bool operator==(const type &l, const type &r) {               \
     return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d;       \
index 7396c12108d0c9c0961ac63d419e20273b14b228..59ada2e0994f3687495dedc5bf95e702084574e2 100644 (file)
@@ -18,8 +18,6 @@
 #include <string>
 #include <include/rados/librados.hpp>
 
-#include "include/cmp.h"
-
 namespace librados {
 struct ListObjectImpl {
   std::string nspace;
@@ -30,12 +28,12 @@ struct ListObjectImpl {
   ListObjectImpl(std::string n, std::string o, std::string l):
       nspace(n), oid(o), locator(l) {}
 
+  auto operator<=>(const ListObjectImpl&) const = default;
+
   const std::string& get_nspace() const { return nspace; }
   const std::string& get_oid() const { return oid; }
   const std::string& get_locator() const { return locator; }
 };
-WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
-WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
 inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) {
   out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid
       << (lop.locator.size() ? "@" + lop.locator : "");
index 789854317f280648848b25d5bc8ebb9a1b4a6b46..5ba4699a2ff5280a5d744b4da5cedd1bf57c7694 100644 (file)
@@ -5,7 +5,6 @@
 #define __CEPH_OS_SEQUENCERPOSITION_H
 
 #include "include/types.h"
-#include "include/cmp.h"
 #include "include/encoding.h"
 #include "common/Formatter.h"
 
@@ -21,6 +20,8 @@ struct SequencerPosition {
 
   SequencerPosition(uint64_t s=0, int32_t t=0, int32_t o=0) : seq(s), trans(t), op(o) {}
 
+  auto operator<=>(const SequencerPosition&) const = default;
+
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(seq, bl);
@@ -52,8 +53,4 @@ inline std::ostream& operator<<(std::ostream& out, const SequencerPosition& t) {
   return out << t.seq << "." << t.trans << "." << t.op;
 }
 
-WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
-WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)
-
-
 #endif