From 8010b2661ae37c4782ed13f9c51785c06268bbe5 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 5 Mar 2022 18:42:40 +0000 Subject: [PATCH 1/2] Add inlines for basic functions in fixnum which weren't being inlined --- agb-fixnum/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index d093dba3..2385fc36 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -68,15 +68,19 @@ pub trait FixedWidthSignedInteger: FixedWidthUnsignedInteger + Neg { impl FixedWidthUnsignedInteger for $T { + #[inline(always)] fn zero() -> Self { 0 } + #[inline(always)] fn one() -> Self { 1 } + #[inline(always)] fn ten() -> Self { 10 } + #[inline(always)] fn from_as_i32(v: i32) -> Self { v as $T } @@ -87,6 +91,7 @@ macro_rules! fixed_width_unsigned_integer_impl { macro_rules! fixed_width_signed_integer_impl { ($T: ty) => { impl FixedWidthSignedInteger for $T { + #[inline(always)] fn fixed_abs(self) -> Self { self.abs() } From 6690538781104411a3dfe03a1b9d8ff94288b4ef Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 5 Mar 2022 18:51:17 +0000 Subject: [PATCH 2/2] Some inlines in SoundChannel which weren't being inlined for some reason --- agb/src/sound/mixer/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/agb/src/sound/mixer/mod.rs b/agb/src/sound/mixer/mod.rs index 7b26c03a..d537d3cc 100644 --- a/agb/src/sound/mixer/mod.rs +++ b/agb/src/sound/mixer/mod.rs @@ -43,6 +43,7 @@ pub struct SoundChannel { } impl SoundChannel { + #[inline(always)] pub fn new(data: &'static [u8]) -> Self { SoundChannel { data, @@ -57,6 +58,7 @@ impl SoundChannel { } } + #[inline(always)] pub fn new_high_priority(data: &'static [u8]) -> Self { SoundChannel { data, @@ -71,16 +73,19 @@ impl SoundChannel { } } + #[inline(always)] pub fn should_loop(&mut self) -> &mut Self { self.should_loop = true; self } + #[inline(always)] pub fn playback(&mut self, playback_speed: Num) -> &mut Self { self.playback_speed = playback_speed; self } + #[inline(always)] pub fn panning(&mut self, panning: Num) -> &mut Self { debug_assert!(panning >= Num::new(-1), "panning value must be >= -1"); debug_assert!(panning <= Num::new(1), "panning value must be <= 1"); @@ -89,6 +94,7 @@ impl SoundChannel { self } + #[inline(always)] pub fn volume(&mut self, volume: Num) -> &mut Self { assert!(volume <= Num::new(1), "volume must be <= 1"); assert!(volume >= Num::new(0), "volume must be >= 0"); @@ -97,12 +103,14 @@ impl SoundChannel { self } + #[inline(always)] pub fn stereo(&mut self) -> &mut Self { self.is_stereo = true; self } + #[inline(always)] pub fn stop(&mut self) { self.is_done = true }