From d11dbe04b9855ee3d9f1b6e693a4b2b1350af335 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 6 Jun 2016 17:38:42 -0400 Subject: [PATCH] common/histogram: use cbits helper Signed-off-by: Sage Weil --- src/common/histogram.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/common/histogram.h b/src/common/histogram.h index 520b516eed5a2..377e212624c0e 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