From: Sage Weil Date: Thu, 23 Jul 2015 13:24:09 +0000 (-0400) Subject: hobject_t: typed MIN_* helpers X-Git-Tag: v9.1.0~346^2~35 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6038aeffed975f9b2664fe4403e87ce3a6010058;p=ceph.git hobject_t: typed MIN_* helpers Signed-off-by: Sage Weil --- diff --git a/src/common/hobject.h b/src/common/hobject.h index b5f8b363abce..d1d9c02abac0 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -299,6 +299,21 @@ static inline int cmp(const hobject_t& l, const hobject_t& r, bool sort_bitwise) return cmp_nibblewise(l, r); } +// these are convenient +static inline hobject_t MAX_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) { + if (cmp(l, r, bitwise) >= 0) + return l; + else + return r; +} + +static inline hobject_t MIN_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) { + if (cmp(l, r, bitwise) <= 0) + return l; + else + return r; +} + typedef version_t gen_t; struct ghobject_t { @@ -440,4 +455,21 @@ static inline int cmp(const ghobject_t& l, const ghobject_t& r, return cmp_nibblewise(l, r); } +// these are convenient +static inline ghobject_t MAX_GHOBJ(const ghobject_t& l, const ghobject_t& r, + bool bitwise) { + if (cmp(l, r, bitwise) >= 0) + return l; + else + return r; +} + +static inline ghobject_t MIN_GHOBJ(const ghobject_t& l, const ghobject_t& r, + bool bitwise) { + if (cmp(l, r, bitwise) <= 0) + return l; + else + return r; +} + #endif