diff --git a/src/lib.rs b/src/lib.rs index 8cbab55..56e8860 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1045,10 +1045,9 @@ impl Del2 { .store(NO_LEARNED_NOTE, Ordering::SeqCst); } } + fn prepare_for_delay(&mut self, buffer_samples: usize) { - // Cache the current tap value to reduce atomic loads let tap_counter = self.params.tap_counter.load(Ordering::SeqCst); - let samples_since_last_event = self.samples_since_last_event; // Cache to a local variable match self.counting_state { CountingState::TimeOut => {} CountingState::CountingInBuffer => { @@ -1074,6 +1073,8 @@ impl Del2 { } } + let samples_since_last_event = self.samples_since_last_event; + // Calculate the current time based on whether there are taps let current_time = if tap_counter > 0 { let last_delay_time = self.params.delay_times[tap_counter - 1].load(Ordering::SeqCst);