Add a bunch of `#[inline]`

This commit is contained in:
Emil Ernerfeldt 2023-12-18 17:22:31 +01:00
parent a726e656a4
commit 4060d02f27
2 changed files with 7 additions and 0 deletions

View File

@ -145,12 +145,14 @@ pub enum SizeHint {
} }
impl Default for SizeHint { impl Default for SizeHint {
#[inline]
fn default() -> Self { fn default() -> Self {
Self::Scale(1.0.ord()) Self::Scale(1.0.ord())
} }
} }
impl From<Vec2> for SizeHint { impl From<Vec2> for SizeHint {
#[inline]
fn from(value: Vec2) -> Self { fn from(value: Vec2) -> Self {
Self::Size(value.x.round() as u32, value.y.round() as u32) 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 { impl<'a> From<&'a TextureHandle> for SizedTexture {
#[inline]
fn from(handle: &'a TextureHandle) -> Self { fn from(handle: &'a TextureHandle) -> Self {
Self::from_handle(handle) Self::from_handle(handle)
} }
@ -435,6 +438,7 @@ pub enum TexturePoll {
} }
impl TexturePoll { impl TexturePoll {
#[inline]
pub fn size(self) -> Option<Vec2> { pub fn size(self) -> Option<Vec2> {
match self { match self {
TexturePoll::Pending { size } => size, TexturePoll::Pending { size } => size,

View File

@ -409,6 +409,7 @@ impl Rect {
/// Linearly interpolate so that `[0, 0]` is [`Self::min`] and /// Linearly interpolate so that `[0, 0]` is [`Self::min`] and
/// `[1, 1]` is [`Self::max`]. /// `[1, 1]` is [`Self::max`].
#[inline]
pub fn lerp_inside(&self, t: Vec2) -> Pos2 { pub fn lerp_inside(&self, t: Vec2) -> Pos2 {
Pos2 { Pos2 {
x: lerp(self.min.x..=self.max.x, t.x), x: lerp(self.min.x..=self.max.x, t.x),
@ -417,6 +418,7 @@ impl Rect {
} }
/// Linearly self towards other rect. /// Linearly self towards other rect.
#[inline]
pub fn lerp_towards(&self, other: &Rect, t: f32) -> Self { pub fn lerp_towards(&self, other: &Rect, t: f32) -> Self {
Self { Self {
min: self.min.lerp(other.min, t), 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) /// from (min, max) or (left top, right bottom)
impl From<[Pos2; 2]> for Rect { impl From<[Pos2; 2]> for Rect {
#[inline]
fn from([min, max]: [Pos2; 2]) -> Self { fn from([min, max]: [Pos2; 2]) -> Self {
Self { min, max } Self { min, max }
} }