mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
Merge pull request #177 from gwilymk/strategic-inlines
Strategic inlines
This commit is contained in:
commit
e77a1c26a3
|
@ -68,15 +68,19 @@ pub trait FixedWidthSignedInteger: FixedWidthUnsignedInteger + Neg<Output = Self
|
||||||
macro_rules! fixed_width_unsigned_integer_impl {
|
macro_rules! fixed_width_unsigned_integer_impl {
|
||||||
($T: ty) => {
|
($T: ty) => {
|
||||||
impl FixedWidthUnsignedInteger for $T {
|
impl FixedWidthUnsignedInteger for $T {
|
||||||
|
#[inline(always)]
|
||||||
fn zero() -> Self {
|
fn zero() -> Self {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
#[inline(always)]
|
||||||
fn one() -> Self {
|
fn one() -> Self {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
#[inline(always)]
|
||||||
fn ten() -> Self {
|
fn ten() -> Self {
|
||||||
10
|
10
|
||||||
}
|
}
|
||||||
|
#[inline(always)]
|
||||||
fn from_as_i32(v: i32) -> Self {
|
fn from_as_i32(v: i32) -> Self {
|
||||||
v as $T
|
v as $T
|
||||||
}
|
}
|
||||||
|
@ -87,6 +91,7 @@ macro_rules! fixed_width_unsigned_integer_impl {
|
||||||
macro_rules! fixed_width_signed_integer_impl {
|
macro_rules! fixed_width_signed_integer_impl {
|
||||||
($T: ty) => {
|
($T: ty) => {
|
||||||
impl FixedWidthSignedInteger for $T {
|
impl FixedWidthSignedInteger for $T {
|
||||||
|
#[inline(always)]
|
||||||
fn fixed_abs(self) -> Self {
|
fn fixed_abs(self) -> Self {
|
||||||
self.abs()
|
self.abs()
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ pub struct SoundChannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SoundChannel {
|
impl SoundChannel {
|
||||||
|
#[inline(always)]
|
||||||
pub fn new(data: &'static [u8]) -> Self {
|
pub fn new(data: &'static [u8]) -> Self {
|
||||||
SoundChannel {
|
SoundChannel {
|
||||||
data,
|
data,
|
||||||
|
@ -57,6 +58,7 @@ impl SoundChannel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn new_high_priority(data: &'static [u8]) -> Self {
|
pub fn new_high_priority(data: &'static [u8]) -> Self {
|
||||||
SoundChannel {
|
SoundChannel {
|
||||||
data,
|
data,
|
||||||
|
@ -71,16 +73,19 @@ impl SoundChannel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn should_loop(&mut self) -> &mut Self {
|
pub fn should_loop(&mut self) -> &mut Self {
|
||||||
self.should_loop = true;
|
self.should_loop = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn playback(&mut self, playback_speed: Num<usize, 8>) -> &mut Self {
|
pub fn playback(&mut self, playback_speed: Num<usize, 8>) -> &mut Self {
|
||||||
self.playback_speed = playback_speed;
|
self.playback_speed = playback_speed;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn panning(&mut self, panning: Num<i16, 4>) -> &mut Self {
|
pub fn panning(&mut self, panning: Num<i16, 4>) -> &mut Self {
|
||||||
debug_assert!(panning >= Num::new(-1), "panning value must be >= -1");
|
debug_assert!(panning >= Num::new(-1), "panning value must be >= -1");
|
||||||
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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn volume(&mut self, volume: Num<i16, 4>) -> &mut Self {
|
pub fn volume(&mut self, volume: Num<i16, 4>) -> &mut Self {
|
||||||
assert!(volume <= Num::new(1), "volume must be <= 1");
|
assert!(volume <= Num::new(1), "volume must be <= 1");
|
||||||
assert!(volume >= Num::new(0), "volume must be >= 0");
|
assert!(volume >= Num::new(0), "volume must be >= 0");
|
||||||
|
@ -97,12 +103,14 @@ impl SoundChannel {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn stereo(&mut self) -> &mut Self {
|
pub fn stereo(&mut self) -> &mut Self {
|
||||||
self.is_stereo = true;
|
self.is_stereo = true;
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn stop(&mut self) {
|
pub fn stop(&mut self) {
|
||||||
self.is_done = true
|
self.is_done = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue