From 352658f23facf6cf8aa9feb883ed68a42d8877c9 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sun, 23 Jul 2023 19:08:51 +0100 Subject: [PATCH] Fix clippy lints --- agb/src/sound/mixer/sw_mixer.rs | 2 +- tracker/agb-tracker-interop/src/lib.rs | 3 +-- tracker/agb-tracker/src/lib.rs | 11 +++++++---- tracker/agb-xm-core/src/lib.rs | 8 +++++--- tracker/agb-xm-core/src/main.rs | 8 -------- 5 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 tracker/agb-xm-core/src/main.rs diff --git a/agb/src/sound/mixer/sw_mixer.rs b/agb/src/sound/mixer/sw_mixer.rs index 4915e7a7..26556f97 100644 --- a/agb/src/sound/mixer/sw_mixer.rs +++ b/agb/src/sound/mixer/sw_mixer.rs @@ -504,7 +504,7 @@ impl MixerBuffer { for j in i..self.frequency.buffer_size() { // SAFETY: working buffer length = self.frequency.buffer_size() unsafe { - *working_buffer_i32.get_unchecked_mut(j) = 0.into(); + *working_buffer_i32.get_unchecked_mut(j) = 0; } } } diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index ba7aa5f5..38388b96 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -114,8 +114,7 @@ impl<'a> quote::ToTokens for Sample<'a> { volume, } = self; - let self_as_u8s: Vec<_> = data.iter().map(|i| *i as u8).collect(); - let samples = ByteString(&self_as_u8s); + let samples = ByteString(data); let volume = volume.to_raw(); tokens.append_all(quote! { diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index 5a05f3ae..35368977 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -135,10 +135,13 @@ impl Tracker { impl TrackerChannel { fn play_sound(&mut self, mixer: &mut Mixer<'_>, sample: &Sample<'static>) { - self.channel_id + if let Some(channel) = self + .channel_id .take() .and_then(|channel_id| mixer.channel(&channel_id)) - .map(|channel| channel.stop()); + { + channel.stop(); + } let mut new_channel = SoundChannel::new(sample.data); @@ -158,7 +161,7 @@ impl TrackerChannel { if let Some(channel) = self .channel_id .as_ref() - .and_then(|channel_id| mixer.channel(&channel_id)) + .and_then(|channel_id| mixer.channel(channel_id)) { if speed != 0.into() { self.base_speed = speed; @@ -172,7 +175,7 @@ impl TrackerChannel { if let Some(channel) = self .channel_id .as_ref() - .and_then(|channel_id| mixer.channel(&channel_id)) + .and_then(|channel_id| mixer.channel(channel_id)) { match effect { PatternEffect::None => {} diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index f33d0f95..c75d076e 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -14,7 +14,7 @@ use xmrs::{prelude::*, xm::xmmodule::XmModule}; pub fn agb_xm_core(args: TokenStream) -> TokenStream { let input = match syn::parse::(args.into()) { Ok(input) => input, - Err(err) => return proc_macro2::TokenStream::from(err.to_compile_error()), + Err(err) => return err.to_compile_error(), }; let filename = input.value(); @@ -61,7 +61,9 @@ pub fn parse_module(module: &Module) -> TokenStream { let mut samples = vec![]; for (instrument_index, instrument) in instruments.iter().enumerate() { - let InstrumentType::Default(ref instrument) = instrument.instr_type else { continue; }; + let InstrumentType::Default(ref instrument) = instrument.instr_type else { + continue; + }; for (sample_index, sample) in instrument.sample.iter().enumerate() { let should_loop = !matches!(sample.flags, LoopType::No); @@ -340,7 +342,7 @@ fn note_to_speed( fn note_to_frequency_linear(note: Note, fine_tune: f64, relative_note: i8) -> f64 { let real_note = (note as usize as f64) + (relative_note as f64); - let period = 10.0 * 12.0 * 16.0 * 4.0 - (real_note as f64) * 16.0 * 4.0 - fine_tune / 2.0; + let period = 10.0 * 12.0 * 16.0 * 4.0 - real_note * 16.0 * 4.0 - fine_tune / 2.0; 8363.0 * 2.0f64.powf((6.0 * 12.0 * 16.0 * 4.0 - period) / (12.0 * 16.0 * 4.0)) } diff --git a/tracker/agb-xm-core/src/main.rs b/tracker/agb-xm-core/src/main.rs deleted file mode 100644 index 026485eb..00000000 --- a/tracker/agb-xm-core/src/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() -> Result<(), Box> { - let module = agb_xm_core::load_module_from_file(&std::path::Path::new( - "../agb-tracker/examples/final_countdown.xm", - ))?; - let output = agb_xm_core::parse_module(&module); - - Ok(()) -}