1
0
Fork 0

Explicitly mark parameter range conversions inline

The compiler already does this, but these should be inlineable.
This commit is contained in:
Robbert van der Helm 2023-03-03 22:55:35 +01:00
parent ae3356dca8
commit d3cb5f2bee
4 changed files with 10 additions and 0 deletions

View file

@ -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
}

View file

@ -191,10 +191,12 @@ impl<T: Enum + PartialEq> Param for EnumParam<T> {
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)
}

View file

@ -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 {

View file

@ -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)
}