Preallocate ring buffer result size

This commit is contained in:
Herbert Wolverson
2023-01-19 15:34:53 +00:00
parent d0dd559f1d
commit 9c135e8b4f

View File

@@ -59,7 +59,7 @@ impl ThroughputRingbuffer {
}
pub fn get_result(&self) -> Vec<ThroughputPerSecond> {
let mut result = Vec::new();
let mut result = Vec::with_capacity(RINGBUFFER_SAMPLES);
for i in self.next..RINGBUFFER_SAMPLES {
result.push(self.readings[i]);