]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
hobject_t: typed MIN_* helpers
authorSage Weil <sage@redhat.com>
Thu, 23 Jul 2015 13:24:09 +0000 (09:24 -0400)
committerSage Weil <sage@redhat.com>
Fri, 7 Aug 2015 14:16:03 +0000 (10:16 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/hobject.h

index b5f8b363abcef24fc9bfd7203bbbc49c1a21bf38..d1d9c02abac06f0a60663bfe616b1d82e4a05ebd 100644 (file)
@@ -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