From: Sage Weil Date: Mon, 6 Jun 2016 21:38:42 +0000 (-0400) Subject: common/histogram: use cbits helper X-Git-Tag: v11.0.0~162^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d11dbe04b9855ee3d9f1b6e693a4b2b1350af335;p=ceph.git common/histogram: use cbits helper Signed-off-by: Sage Weil --- diff --git a/src/common/histogram.h b/src/common/histogram.h index 520b516eed5a..377e212624c0 100644 --- a/src/common/histogram.h +++ b/src/common/histogram.h @@ -16,6 +16,7 @@ #include #include +#include "include/intarith.h" #include "include/encoding.h" namespace ceph { @@ -59,21 +60,12 @@ public: } void add(int32_t v) { - int bin = calc_bits_of(v); + int bin = cbits(v); _expand_to(bin + 1); h[bin]++; _contract(); } - static int calc_bits_of(int t) { - int b = 0; - while (t > 0) { - t = t >> 1; - b++; - } - return b; - } - bool operator==(const pow2_hist_t &r) const { return h == r.h; } @@ -89,7 +81,7 @@ public: int get_position_micro(int32_t v, uint64_t *lower, uint64_t *upper) { if (v < 0) return -1; - unsigned bin = calc_bits_of(v); + unsigned bin = cbits(v); uint64_t lower_sum = 0, upper_sum = 0, total = 0; for (unsigned i=0; i