Modulo is very slow, so we try to avoid it inside loops.
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
if let Some(v) = data[i] {
self.data[index] = v;
}
- index += 1;
- if index >= self.data.len() { index = 0; }
+ index += 1; if index >= self.data.len() { index = 0; }
}
Ok(())
}
let mut index = ((t/reso) % num_entries) as usize;
for _ in 0..num_entries {
t += reso;
- index = (index + 1) % (num_entries as usize);
+ index += 1; if index >= self.data.len() { index = 0; }
if t < min_time {
self.data[index] = f64::NAN;
} else {
list.push(Some(value));
}
}
- t += reso; index = (index + 1) % (num_entries as usize);
+ t += reso;
+ index += 1; if index >= self.data.len() { index = 0; }
}
(start, reso, list)