Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Unified Diff: base/histogram.cc

Issue 273065: Remove special code fro calculating bucket index in linear histograms... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/histogram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/histogram.cc
===================================================================
--- base/histogram.cc (revision 28693)
+++ base/histogram.cc (working copy)
@@ -401,11 +401,10 @@
declared_max,
bucket_count);
} else if (histogram_type == LINEAR) {
- render_histogram = reinterpret_cast<Histogram*>
- (new LinearHistogram(histogram_name.c_str(),
- declared_min,
- declared_max,
- bucket_count));
+ render_histogram = new LinearHistogram(histogram_name.c_str(),
+ declared_min,
+ declared_max,
+ bucket_count);
} else {
LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " <<
histogram_type;
@@ -584,17 +583,6 @@
}
}
-// Find bucket to increment for sample value.
-size_t LinearHistogram::BucketIndex(Sample value) const {
- if (value < declared_min()) return 0;
- if (value >= declared_max()) return bucket_count() - 1;
- size_t index;
- index = static_cast<size_t>(((value - declared_min()) * (bucket_count() - 2))
- / (declared_max() - declared_min()) + 1);
- DCHECK(1 <= index && bucket_count() > index);
- return index;
-}
-
double LinearHistogram::GetBucketSize(Count current, size_t i) const {
DCHECK(ranges(i + 1) > ranges(i));
// Adjacent buckets with different widths would have "surprisingly" many (few)
@@ -673,9 +661,10 @@
const std::string name = histogram->histogram_name();
AutoLock auto_lock(*lock_);
- DCHECK(histograms_->end() == histograms_->find(name)) << name << " is already"
- "registered as a histogram. Check for duplicate use of the name, or a "
- "race where a static initializer could be run by several threads.";
+ if (histograms_->end() != histograms_->find(name)) {
+ // Check to be sure it is compatible.... and if not, then do a CHECK()
+ return false; // This name is already registered.
+ }
(*histograms_)[name] = histogram;
return true;
}
« no previous file with comments | « base/histogram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698