mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 684091. Add the ability to subtract values from Histograms. r=taras
This is a copy of Add where we Accumulate with -1 instead of 1. I'm doing this as a copy instead of factoring out the common code to make this file easier to compare with chromium's histrogram.cc
This commit is contained in:
parent
91be730933
commit
6969654308
@ -130,6 +130,17 @@ void Histogram::Add(int value) {
|
||||
Accumulate(value, 1, index);
|
||||
}
|
||||
|
||||
void Histogram::Subtract(int value) {
|
||||
if (value > kSampleType_MAX - 1)
|
||||
value = kSampleType_MAX - 1;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
size_t index = BucketIndex(value);
|
||||
DCHECK_GE(value, ranges(index));
|
||||
DCHECK_LT(value, ranges(index + 1));
|
||||
Accumulate(value, -1, index);
|
||||
}
|
||||
|
||||
void Histogram::AddBoolean(bool value) {
|
||||
DCHECK(false);
|
||||
}
|
||||
|
@ -381,6 +381,7 @@ class Histogram {
|
||||
Flags flags);
|
||||
|
||||
void Add(int value);
|
||||
void Subtract(int value);
|
||||
|
||||
// This method is an interface, used only by BooleanHistogram.
|
||||
virtual void AddBoolean(bool value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user