From: Somnath Roy Date: Wed, 22 Jan 2014 19:03:06 +0000 (-0800) Subject: cmp.h: boost tuple comparison is replaced by regular comparison X-Git-Tag: v0.78~231^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5fde828dac589d8fbed81ed48d72da572d2424df;p=ceph.git cmp.h: boost tuple comparison is replaced by regular comparison Profiler was showing this boost tuple comparison is expensive. So, it is replaced by regular comparison. Signed-off-by: Somnath Roy Signed-off-by: Greg Farnum --- diff --git a/src/include/cmp.h b/src/include/cmp.h index d660c1923b0c..92ecef479904 100644 --- a/src/include/cmp.h +++ b/src/include/cmp.h @@ -1,7 +1,5 @@ #ifndef __CEPH_CMP_H #define __CEPH_CMP_H -#include -#include /* * macros to define comparison operators for classes with small numbers of members. @@ -104,30 +102,48 @@ (l.d == r.d && l.e <= r.e))))))); \ } -#define WRITE_EQ_OPERATORS_7(type, a, b, c, d, e, f, g) \ - inline bool operator==(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) == \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } \ - inline bool operator!=(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) != \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } -#define WRITE_CMP_OPERATORS_7(type, a, b, c, d, e, f, g) \ - inline bool operator<=(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) <= \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } \ - inline bool operator>=(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) >= \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } \ - inline bool operator>(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) > \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } \ - inline bool operator<(const type &l, const type &r) { \ - return (boost::make_tuple(boost::cref(l.a), boost::cref(l.b), boost::cref(l.c), boost::cref(l.d), boost::cref(l.e), boost::cref(l.f), boost::cref(l.g)) < \ - boost::make_tuple(boost::cref(r.a), boost::cref(r.b), boost::cref(r.c), boost::cref(r.d), boost::cref(r.e), boost::cref(r.f), boost::cref(r.g))); \ - } +#define WRITE_EQ_OPERATORS_7(type, a, b, c, d, e, f, g) \ + inline bool operator==(const type &l, const type &r) { \ + return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d && l.e == r.e && l.f == r.f && l.g == r.g; \ + } \ + inline bool operator!=(const type &l, const type &r) { \ + return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d || l.e != r.e || l.f != r.f || l.g != r.g; \ + } +#define WRITE_CMP_OPERATORS_7(type, a, b, c, d, e, f, g) \ + inline bool operator<=(const type &l, const type &r) { \ + return l.a < r.a || \ + (l.a == r.a && (l.b < r.b || \ + (l.b == r.b && (l.c < r.c || \ + (l.c == r.c && (l.d < r.d || \ + (l.d == r.d && (l.e < r.e || \ + (l.e == r.e && (l.f < r.f || \ + (l.f == r.f && l.g <= r.g))))))))))); \ + } \ + inline bool operator>=(const type &l, const type &r) { \ + return l.a > r.a || \ + (l.a == r.a && (l.b > r.b || \ + (l.b == r.b && (l.c > r.c || \ + (l.c == r.c && (l.d > r.d || \ + (l.d == r.d && (l.e > r.e || \ + (l.e == r.e && (l.f > r.f || \ + (l.f == r.f && l.g >= r.g))))))))))); \ + } \ + inline bool operator>(const type &l, const type &r) { \ + return l.a > r.a || \ + (l.a == r.a && (l.b > r.b || \ + (l.b == r.b && (l.c > r.c || \ + (l.c == r.c && (l.d > r.d || \ + (l.d == r.d && (l.e > r.e || \ + (l.e == r.e && (l.f > r.f || \ + (l.f == r.f && l.g > r.g))))))))))); \ + } \ + inline bool operator<(const type &l, const type &r) { \ + return l.a < r.a || \ + (l.a == r.a && (l.b < r.b || \ + (l.b == r.b && (l.c < r.c || \ + (l.c == r.c && (l.d < r.d || \ + (l.d == r.d && (l.e < r.e || \ + (l.e == r.e && (l.f < r.f || \ + (l.f == r.f && l.g < r.g))))))))))); \ + } #endif