From e686c1b6576686ae8195c3042308723eb865234c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 30 Dec 2011 11:39:30 -0800 Subject: [PATCH] hobject_t: fix operator==, != These weren't comparing key. While we're at it, clean this up by using generic macros for writing these operators, so we don't get it wrong half the time. Signed-off-by: Sage Weil --- src/include/object.h | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/include/object.h b/src/include/object.h index 0b13d61d4c43d..b5654f501e0b5 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -28,6 +28,7 @@ using namespace __gnu_cxx; #include "hash.h" #include "encoding.h" #include "ceph_hash.h" +#include "cmp.h" /* Maximum supported object name length for Ceph, in bytes. * @@ -399,37 +400,9 @@ inline ostream& operator<<(ostream& out, const hobject_t& o) return out; } -// sort hobject_t's by -inline bool operator==(const hobject_t &l, const hobject_t &r) { - return l.oid == r.oid && l.snap == r.snap && l.hash == r.hash && l.max == r.max; -} -inline bool operator!=(const hobject_t &l, const hobject_t &r) { - return l.oid != r.oid || l.snap != r.snap || l.hash != r.hash || l.max != r.max; -} -inline bool operator>(const hobject_t &l, const hobject_t &r) { - return l.max > r.max || - (l.max == r.max && (l.get_filestore_key() > r.get_filestore_key() || - (l.get_filestore_key() == r.get_filestore_key() && (l.get_effective_key() > r.get_effective_key() || - (l.get_effective_key() == r.get_effective_key() && l.snap > r.snap))))); -} -inline bool operator<(const hobject_t &l, const hobject_t &r) { - return l.max < r.max || - (l.max == r.max && (l.get_filestore_key() < r.get_filestore_key() || - (l.get_filestore_key() == r.get_filestore_key() && (l.get_effective_key() < r.get_effective_key() || - (l.get_effective_key() == r.get_effective_key() && l.snap < r.snap))))); -} -inline bool operator>=(const hobject_t &l, const hobject_t &r) { - return l.max > r.max || - (l.max == r.max && (l.get_filestore_key() > r.get_filestore_key() || - (l.get_filestore_key() == r.get_filestore_key() && (l.get_effective_key() > r.get_effective_key() || - (l.get_effective_key() == r.get_effective_key() && l.snap >= r.snap))))); -} -inline bool operator<=(const hobject_t &l, const hobject_t &r) { - return l.max < r.max || - (l.max == r.max && (l.get_filestore_key() < r.get_filestore_key() || - (l.get_filestore_key() == r.get_filestore_key() && (l.get_effective_key() < r.get_effective_key() || - (l.get_effective_key() == r.get_effective_key() && l.snap <= r.snap))))); -} +WRITE_EQ_OPERATORS_5(hobject_t, oid, get_key(), snap, hash, max) +// sort hobject_t's by +WRITE_CMP_OPERATORS_5(hobject_t, max, get_filestore_key(), get_effective_key(), oid, snap) // --------------------------- -- 2.39.5