From fc8aec5afab04251dfdeebc2753ec181c7f146a8 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 15 Feb 2022 00:39:30 +0100 Subject: [PATCH] Explain not using the inner iterator in Diopser --- plugins/diopser/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/diopser/src/lib.rs b/plugins/diopser/src/lib.rs index ee20841f..e2a40d77 100644 --- a/plugins/diopser/src/lib.rs +++ b/plugins/diopser/src/lib.rs @@ -250,9 +250,10 @@ impl Plugin for Diopser { // We get better cache locality by iterating over the filters and then over the channels for filter_idx in 0..self.params.filter_stages.value as usize { - // Because of this filter_idx outer loop we can't directly iterate over - // `channel_samples` as the iterator would be empty after the first loop for (channel_idx, filters) in self.filters.iter_mut().enumerate() { + // We can also use `channel_samples.iter_mut()`, but the compiler isn't able to + // optmize that iterator away and it would add a ton of overhead over indexing + // the buffer directly let sample = unsafe { channel_samples.get_unchecked_mut(channel_idx) }; *sample = filters[filter_idx].process(*sample); }