From: Francesco Chemolli Date: Tue, 6 Dec 2011 14:42:04 +0000 (+0100) Subject: Migrated statHistBin to StatHist::findBin X-Git-Tag: BumpSslServerFirst.take05~12^2~120^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3da5974d62460169a3b5116154a951b845ceae34;p=thirdparty%2Fsquid.git Migrated statHistBin to StatHist::findBin --- diff --git a/src/StatHist.cc b/src/StatHist.cc index e3b4b779af..fa4c7e2695 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -50,7 +50,6 @@ #include "Store.h" /* Local functions */ -static int statHistBin(const StatHist * H, double v); static StatHistBinDumper statHistBinDumper; namespace Math @@ -78,9 +77,9 @@ StatHist::init(int capacity_, hbase_f * val_in_, hbase_f * val_out_, double min_ /* check that functions are valid */ /* a min value should go into bin[0] */ - assert(statHistBin(this, min) == 0); + assert(findBin(min) == 0); /* a max value should go into the last bin */ - assert(statHistBin(this, max) == capacity - 1); + assert(findBin(max) == capacity - 1); /* it is hard to test val_out, here is a crude test */ assert(((int) floor(0.99 + val(0) - min)) == 0); } @@ -111,34 +110,29 @@ StatHist::operator =(const StatHist & src) void StatHist::count(double val) { - const int bin = statHistBin(this, val); + const int bin = findBin(val); assert(bins); /* make sure it got initialized */ assert(0 <= bin && bin < capacity); ++bins[bin]; } -static int -statHistBin(const StatHist * H, double v) +int +StatHist::findBin(double v) { int bin; -#if BROKEN_STAT_HIST_BIN - return 0; - /* NOTREACHED */ -#endif - - v -= H->min; /* offset */ + v -= min; /* offset */ if (v <= 0.0) /* too small */ return 0; - bin = (int) floor(H->scale * H->val_in(v) + 0.5); + bin = (int) floor(scale * val_in(v) + 0.5); if (bin < 0) /* should not happen */ bin = 0; - if (bin >= H->capacity) /* too big */ - bin = H->capacity - 1; + if (bin >= capacity) /* too big */ + bin = capacity - 1; return bin; } diff --git a/src/StatHist.h b/src/StatHist.h index 7299807403..a2ca9e8744 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -62,6 +62,7 @@ public: void intInit(int n); void init(int capacity, hbase_f * val_in, hbase_f * val_out, double min, double max); private: + int findBin(double v); }; /* StatHist */