]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include: drop WRITE_{EQ,CMP}_OPERATORS_2()
authorKefu Chai <tchaikov@gmail.com>
Wed, 3 Aug 2022 02:50:00 +0000 (10:50 +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/common/entity_name.h
src/include/cmp.h
src/osd/osd_types.h
src/osd/scheduler/mClockScheduler.h

index 5e5ab111404a68f9a72c91b3794990aeb7f89b54..c88ebcbbabde05ad83520a047627caf4d7decc9f 100644 (file)
@@ -70,8 +70,10 @@ struct EntityName
 
   friend bool operator<(const EntityName& a, const EntityName& b);
   friend std::ostream& operator<<(std::ostream& out, const EntityName& n);
-  friend bool operator==(const EntityName& a, const EntityName& b);
-  friend bool operator!=(const EntityName& a, const EntityName& b);
+
+  bool operator==(const EntityName& rhs) const noexcept {
+    return type == rhs.type && id == rhs.id;
+  }
 
 private:
   struct str_to_entity_type_t {
@@ -87,6 +89,4 @@ private:
 
 WRITE_CLASS_ENCODER(EntityName)
 
-WRITE_EQ_OPERATORS_2(EntityName, type, id)
-
 #endif
index 6dd6a7b218b7d5577350d41336a7d11af8d469df..442e11430ffb9214b7a5f99ddfac917a61e5672e 100644 (file)
@@ -4,34 +4,6 @@
 /*
  * macros to define comparison operators for classes with small numbers of members.
  */
-
-#define WRITE_EQ_OPERATORS_2(type, a, b)                               \
-  inline bool operator==(const type &l, const type &r) {               \
-    return l.a == r.a && l.b == r.b;                                   \
-  }                                                                    \
-  inline bool operator!=(const type &l, const type &r) {               \
-    return l.a != r.a || l.b != r.b;                                   \
-  }
-
-#define WRITE_CMP_OPERATORS_2(type, a, b)                      \
-  inline bool operator>(const type &l, const type &r) {                        \
-    return l.a > r.a ||                                                        \
-      (l.a == r.a && (l.b > r.b));                                     \
-  }                                                                    \
-  inline bool operator<(const type &l, const type &r) {                        \
-    return l.a < r.a ||                                                        \
-      (l.a == r.a && (l.b < r.b));                                     \
-  }                                                                    \
-  inline bool operator>=(const type &l, const type &r) {               \
-    return l.a > r.a ||                                                        \
-      (l.a == r.a && (l.b >= r.b));                                    \
-  }                                                                    \
-  inline bool operator<=(const type &l, const type &r) {               \
-    return l.a < r.a ||                                                        \
-      (l.a == r.a && (l.b <= r.b));                                    \
-  }
-
-
 #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;                     \
index cf8160ea4f35c3c4c4d35da76213a9fdee4d5a71..2f241d7b248b15ebb8ac8de9bcfe1fdc81a5a246 100644 (file)
@@ -47,7 +47,6 @@
 #include "common/snap_types.h"
 #include "HitSet.h"
 #include "Watch.h"
-#include "include/cmp.h"
 #include "librados/ListObjectImpl.h"
 #include "compressor/Compressor.h"
 #include "osd_perf_counters.h"
@@ -196,10 +195,9 @@ struct pg_shard_t {
       f->dump_unsigned("shard", shard);
     }
   }
+  auto operator<=>(const pg_shard_t&) const = default;
 };
 WRITE_CLASS_ENCODER(pg_shard_t)
-WRITE_EQ_OPERATORS_2(pg_shard_t, osd, shard)
-WRITE_CMP_OPERATORS_2(pg_shard_t, osd, shard)
 std::ostream& operator<<(std::ostream &lhs, const pg_shard_t &rhs);
 
 using HobjToShardSetMapping = std::map<hobject_t, std::set<pg_shard_t>>;
@@ -546,6 +544,7 @@ struct spg_t {
   spg_t() : shard(shard_id_t::NO_SHARD) {}
   spg_t(pg_t pgid, shard_id_t shard) : pgid(pgid), shard(shard) {}
   explicit spg_t(pg_t pgid) : pgid(pgid), shard(shard_id_t::NO_SHARD) {}
+  auto operator<=>(const spg_t&) const = default;
   unsigned get_split_bits(unsigned pg_num) const {
     return pgid.get_split_bits(pg_num);
   }
@@ -639,8 +638,6 @@ struct spg_t {
   }
 };
 WRITE_CLASS_ENCODER(spg_t)
-WRITE_EQ_OPERATORS_2(spg_t, pgid, shard)
-WRITE_CMP_OPERATORS_2(spg_t, pgid, shard)
 
 namespace std {
   template<> struct hash< spg_t >
index cb53412c7e0f8f97f9d465fc97860e866d9914a7..c3b79dba44bcc3cb918300697499dbd96432bd48 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "osd/scheduler/OpScheduler.h"
 #include "common/config.h"
-#include "include/cmp.h"
 #include "common/ceph_context.h"
 #include "common/mClockPriorityQueue.h"
 #include "osd/scheduler/OpSchedulerItem.h"
@@ -43,6 +42,7 @@ struct client_profile_id_t {
   client_id_t client_id;
   profile_id_t profile_id;
 
+  auto operator<=>(const client_profile_id_t&) const = default;
   friend std::ostream& operator<<(std::ostream& out,
                                   const client_profile_id_t& client_profile) {
     out << " client_id: " << client_profile.client_id
@@ -51,14 +51,11 @@ struct client_profile_id_t {
   }
 };
 
-WRITE_EQ_OPERATORS_2(client_profile_id_t, client_id, profile_id)
-WRITE_CMP_OPERATORS_2(client_profile_id_t, client_id, profile_id)
-
-
 struct scheduler_id_t {
   op_scheduler_class class_id;
   client_profile_id_t client_profile_id;
 
+  auto operator<=>(const scheduler_id_t&) const = default;
   friend std::ostream& operator<<(std::ostream& out,
                                   const scheduler_id_t& sched_id) {
     out << "{ class_id: " << sched_id.class_id
@@ -67,9 +64,6 @@ struct scheduler_id_t {
   }
 };
 
-WRITE_EQ_OPERATORS_2(scheduler_id_t, class_id, client_profile_id)
-WRITE_CMP_OPERATORS_2(scheduler_id_t, class_id, client_profile_id)
-
 /**
  * Scheduler implementation based on mclock.
  *