Removed double zeroing of Immix histograms

Immix histograms use a Chunk under the hood, and the memory for a Chunk
is already zeroed upon allocation. Since AtomicUsize has the same memory
representation as usize, we can just leave out the additional zeroing in
Histogram::new().
parent d1496336
Pipeline #38906228 failed with stages
in 8 minutes and 41 seconds
......@@ -24,13 +24,9 @@ pub struct HistogramIterator<'a> {
impl Histogram {
#![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
pub fn new(capacity: usize) -> Self {
let mut chunk = Chunk::new(capacity);
let values = Chunk::new(capacity);
for index in 0..capacity {
chunk[index] = AtomicUsize::new(DEFAULT_VALUE);
}
Histogram { values: chunk }
Histogram { values }
}
/// Increments a bin by the given value.
......@@ -100,6 +96,13 @@ impl<'a> Iterator for HistogramIterator<'a> {
mod tests {
use super::*;
#[test]
fn test_new() {
let histo = Histogram::new(1);
assert_eq!(histo.get(0), 0);
}
#[test]
fn test_increment() {
let histo = Histogram::new(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment