From d3cb5f2beec25569f64aa3afa353d9e1199daee4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 3 Mar 2023 22:55:35 +0100 Subject: [PATCH] Explicitly mark parameter range conversions inline The compiler already does this, but these should be inlineable. --- src/params/boolean.rs | 2 ++ src/params/enums.rs | 4 ++++ src/params/float.rs | 2 ++ src/params/integer.rs | 2 ++ 4 files changed, 10 insertions(+) diff --git a/src/params/boolean.rs b/src/params/boolean.rs index ba807263..abc2a0b6 100644 --- a/src/params/boolean.rs +++ b/src/params/boolean.rs @@ -146,6 +146,7 @@ impl Param for BoolParam { Some(self.preview_normalized(value)) } + #[inline] fn preview_normalized(&self, plain: Self::Plain) -> f32 { if plain { 1.0 @@ -154,6 +155,7 @@ impl Param for BoolParam { } } + #[inline] fn preview_plain(&self, normalized: f32) -> Self::Plain { normalized > 0.5 } diff --git a/src/params/enums.rs b/src/params/enums.rs index b913df16..9b59c509 100644 --- a/src/params/enums.rs +++ b/src/params/enums.rs @@ -191,10 +191,12 @@ impl Param for EnumParam { self.inner.string_to_normalized_value(string) } + #[inline] fn preview_normalized(&self, plain: Self::Plain) -> f32 { self.inner.preview_normalized(T::to_index(plain) as i32) } + #[inline] fn preview_plain(&self, normalized: f32) -> Self::Plain { T::from_index(self.inner.preview_plain(normalized) as usize) } @@ -276,10 +278,12 @@ impl Param for EnumParamInner { .map(|idx| self.preview_normalized(idx as i32)) } + #[inline] fn preview_normalized(&self, plain: Self::Plain) -> f32 { self.inner.preview_normalized(plain) } + #[inline] fn preview_plain(&self, normalized: f32) -> Self::Plain { self.inner.preview_plain(normalized) } diff --git a/src/params/float.rs b/src/params/float.rs index 3f80169a..803ad9e6 100644 --- a/src/params/float.rs +++ b/src/params/float.rs @@ -180,10 +180,12 @@ impl Param for FloatParam { Some(self.preview_normalized(value)) } + #[inline] fn preview_normalized(&self, plain: Self::Plain) -> f32 { self.range.normalize(plain) } + #[inline] fn preview_plain(&self, normalized: f32) -> Self::Plain { let value = self.range.unnormalize(normalized); match &self.step_size { diff --git a/src/params/integer.rs b/src/params/integer.rs index d6ecc22d..13a2575f 100644 --- a/src/params/integer.rs +++ b/src/params/integer.rs @@ -164,10 +164,12 @@ impl Param for IntParam { Some(self.preview_normalized(value)) } + #[inline] fn preview_normalized(&self, plain: Self::Plain) -> f32 { self.range.normalize(plain) } + #[inline] fn preview_plain(&self, normalized: f32) -> Self::Plain { self.range.unnormalize(normalized) }