mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Optimize: add #[inline(always)] to various low-level things
saves up to 20% (text tesselation), and at least 5% overall
This commit is contained in:
@@ -92,11 +92,13 @@ pub trait One {
|
||||
fn one() -> Self;
|
||||
}
|
||||
impl One for f32 {
|
||||
#[inline(always)]
|
||||
fn one() -> Self {
|
||||
1.0
|
||||
}
|
||||
}
|
||||
impl One for f64 {
|
||||
#[inline(always)]
|
||||
fn one() -> Self {
|
||||
1.0
|
||||
}
|
||||
@@ -121,6 +123,7 @@ impl Real for f64 {}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// Linear interpolation.
|
||||
#[inline(always)]
|
||||
pub fn lerp<R, T>(range: RangeInclusive<R>, t: T) -> R
|
||||
where
|
||||
T: Real + Mul<R, Output = R>,
|
||||
@@ -309,9 +312,11 @@ pub trait NumExt {
|
||||
macro_rules! impl_num_ext {
|
||||
($t: ty) => {
|
||||
impl NumExt for $t {
|
||||
#[inline(always)]
|
||||
fn at_least(self, lower_limit: Self) -> Self {
|
||||
self.max(lower_limit)
|
||||
}
|
||||
#[inline(always)]
|
||||
fn at_most(self, upper_limit: Self) -> Self {
|
||||
self.min(upper_limit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user