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

Side by Side Diff: base/metrics/bucket_ranges.cc

Issue 2949983002: Inline BucketRanges::set_range (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« base/metrics/bucket_ranges.h ('K') | « base/metrics/bucket_ranges.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/bucket_ranges.h" 5 #include "base/metrics/bucket_ranges.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 return sum; 103 return sum;
104 } 104 }
105 105
106 BucketRanges::BucketRanges(size_t num_ranges) 106 BucketRanges::BucketRanges(size_t num_ranges)
107 : ranges_(num_ranges, 0), 107 : ranges_(num_ranges, 0),
108 checksum_(0) {} 108 checksum_(0) {}
109 109
110 BucketRanges::~BucketRanges() {} 110 BucketRanges::~BucketRanges() {}
111 111
112 void BucketRanges::set_range(size_t i, HistogramBase::Sample value) {
113 DCHECK_LT(i, ranges_.size());
114 CHECK_GE(value, 0);
115 ranges_[i] = value;
116 }
117
118 uint32_t BucketRanges::CalculateChecksum() const { 112 uint32_t BucketRanges::CalculateChecksum() const {
119 // Seed checksum. 113 // Seed checksum.
120 uint32_t checksum = static_cast<uint32_t>(ranges_.size()); 114 uint32_t checksum = static_cast<uint32_t>(ranges_.size());
121 115
122 for (size_t index = 0; index < ranges_.size(); ++index) 116 for (size_t index = 0; index < ranges_.size(); ++index)
123 checksum = Crc32(checksum, ranges_[index]); 117 checksum = Crc32(checksum, ranges_[index]);
124 return checksum; 118 return checksum;
125 } 119 }
126 120
127 bool BucketRanges::HasValidChecksum() const { 121 bool BucketRanges::HasValidChecksum() const {
(...skipping 10 matching lines...) Expand all
138 if (ranges_.size() != other->ranges_.size()) 132 if (ranges_.size() != other->ranges_.size())
139 return false; 133 return false;
140 for (size_t index = 0; index < ranges_.size(); ++index) { 134 for (size_t index = 0; index < ranges_.size(); ++index) {
141 if (ranges_[index] != other->ranges_[index]) 135 if (ranges_[index] != other->ranges_[index])
142 return false; 136 return false;
143 } 137 }
144 return true; 138 return true;
145 } 139 }
146 140
147 } // namespace base 141 } // namespace base
OLDNEW
« base/metrics/bucket_ranges.h ('K') | « base/metrics/bucket_ranges.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698