From 4060d02f27c9ccca027c26f9297bafff46f484b3 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 18 Dec 2023 17:22:31 +0100 Subject: [PATCH] Add a bunch of `#[inline]` --- crates/egui/src/load.rs | 4 ++++ crates/emath/src/rect.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index f1c61a64..b39e4812 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -145,12 +145,14 @@ pub enum SizeHint { } impl Default for SizeHint { + #[inline] fn default() -> Self { Self::Scale(1.0.ord()) } } impl From for SizeHint { + #[inline] fn from(value: Vec2) -> Self { Self::Size(value.x.round() as u32, value.y.round() as u32) } @@ -412,6 +414,7 @@ impl From<(TextureId, Vec2)> for SizedTexture { } impl<'a> From<&'a TextureHandle> for SizedTexture { + #[inline] fn from(handle: &'a TextureHandle) -> Self { Self::from_handle(handle) } @@ -435,6 +438,7 @@ pub enum TexturePoll { } impl TexturePoll { + #[inline] pub fn size(self) -> Option { match self { TexturePoll::Pending { size } => size, diff --git a/crates/emath/src/rect.rs b/crates/emath/src/rect.rs index e671135f..16f5633a 100644 --- a/crates/emath/src/rect.rs +++ b/crates/emath/src/rect.rs @@ -409,6 +409,7 @@ impl Rect { /// Linearly interpolate so that `[0, 0]` is [`Self::min`] and /// `[1, 1]` is [`Self::max`]. + #[inline] pub fn lerp_inside(&self, t: Vec2) -> Pos2 { Pos2 { x: lerp(self.min.x..=self.max.x, t.x), @@ -417,6 +418,7 @@ impl Rect { } /// Linearly self towards other rect. + #[inline] pub fn lerp_towards(&self, other: &Rect, t: f32) -> Self { Self { min: self.min.lerp(other.min, t), @@ -611,6 +613,7 @@ impl std::fmt::Debug for Rect { /// from (min, max) or (left top, right bottom) impl From<[Pos2; 2]> for Rect { + #[inline] fn from([min, max]: [Pos2; 2]) -> Self { Self { min, max } }