Skip to content

Commit d5f85e7

Browse files
Better value_from_loc comment
1 parent efd9ca7 commit d5f85e7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,8 +1241,10 @@ impl<T: Counter> Histogram<T> {
12411241

12421242
#[inline]
12431243
fn value_from_loc(&self, bucket_index: u8, sub_bucket_index: u32) -> u64 {
1244-
// sum won't overflow; bucket_index and unit_magnitude are both <= 64.
1245-
// However, the resulting shift may overflow if unit magnitude is large, for instance.
1244+
// Sum won't overflow; bucket_index and unit_magnitude are both <= 64.
1245+
// However, the resulting shift may overflow given bogus input, e.g. if unit magnitude is
1246+
// large and the input sub_bucket_index is for an entry in the counts index that shouldn't
1247+
// be used (because this calculation will overflow).
12461248
(sub_bucket_index as u64) << (bucket_index + self.unit_magnitude)
12471249
}
12481250

0 commit comments

Comments
 (0)