From 8e2346ebbcc16c3bc873d082e1b7fa6f22b2d1ed Mon Sep 17 00:00:00 2001 From: Andrew Minnich Date: Tue, 24 Dec 2024 03:54:43 -0500 Subject: [PATCH] code style --- crates/kira/src/sound/static_sound/sound.rs | 11 +++-------- crates/kira/src/sound/static_sound/sound/resampler.rs | 4 +--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/kira/src/sound/static_sound/sound.rs b/crates/kira/src/sound/static_sound/sound.rs index b0c02e44..65e08dec 100644 --- a/crates/kira/src/sound/static_sound/sound.rs +++ b/crates/kira/src/sound/static_sound/sound.rs @@ -139,14 +139,9 @@ impl StaticSound { } fn push_frame_to_resampler(&mut self) { - let frame = if self.transport.playing { - Some( - frame_at_index(self.transport.position, &self.frames, self.slice) - .unwrap_or_default(), - ) - } else { - None - }; + let frame = self.transport.playing.then(|| { + frame_at_index(self.transport.position, &self.frames, self.slice).unwrap_or_default() + }); self.resampler.push_frame(frame, self.transport.position); } diff --git a/crates/kira/src/sound/static_sound/sound/resampler.rs b/crates/kira/src/sound/static_sound/sound/resampler.rs index 82fff9ef..b5f40e43 100644 --- a/crates/kira/src/sound/static_sound/sound/resampler.rs +++ b/crates/kira/src/sound/static_sound/sound/resampler.rs @@ -33,9 +33,7 @@ impl Resampler { self.time_until_empty = self.time_until_empty.saturating_sub(1); } let frame = frame.unwrap_or_default(); - for i in 0..self.frames.len() - 1 { - self.frames[i] = self.frames[i + 1]; - } + self.frames.copy_within(1.., 0); self.frames[self.frames.len() - 1] = RecentFrame { frame, frame_index: sample_index,