From: Kefu Chai Date: Wed, 3 Aug 2022 02:50:00 +0000 (+0800) Subject: include: drop WRITE_{EQ,CMP}_OPERATORS_2() X-Git-Tag: v18.0.0~339^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e9a110aaa3233d11628ec95ed17745b7a5cd546f;p=ceph.git include: drop WRITE_{EQ,CMP}_OPERATORS_2() the default-generated comparison operators can fulfill our needs. Signed-off-by: Kefu Chai --- diff --git a/src/common/entity_name.h b/src/common/entity_name.h index 5e5ab111404a6..c88ebcbbabde0 100644 --- a/src/common/entity_name.h +++ b/src/common/entity_name.h @@ -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 diff --git a/src/include/cmp.h b/src/include/cmp.h index 6dd6a7b218b7d..442e11430ffb9 100644 --- a/src/include/cmp.h +++ b/src/include/cmp.h @@ -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; \ diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index cf8160ea4f35c..2f241d7b248b1 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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>; @@ -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 > diff --git a/src/osd/scheduler/mClockScheduler.h b/src/osd/scheduler/mClockScheduler.h index cb53412c7e0f8..c3b79dba44bcc 100644 --- a/src/osd/scheduler/mClockScheduler.h +++ b/src/osd/scheduler/mClockScheduler.h @@ -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. *