perf: inline public getters/setters, and use non-generic inner functions

To reduce compile-times and avoid some overhead to binary size, this will modify some of our
generic functions to use non-generic inner functions where possible. The inner functions are
marked carefully with `#[inline(never)]` to prevent being inlined by LLVM at their callsites

While looking for generic functions to optimize, I have also taken the opportunity to annotate
public non-generic getters and setters with `#[inline]` to ensure that LLVM will inline them
across crate boundaries. By default, only generic functions are automatically inlined, and
only when enabling fat LTO are constant functions reliably inlined across crate boundaries.
This commit is contained in:
Michael Aaron Murphy 2025-03-21 03:17:59 +01:00
parent c538d672df
commit 8cf372c9b9
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
55 changed files with 702 additions and 255 deletions

View file

@ -69,6 +69,7 @@ where
/// Sets the width of the [`self.`].
#[must_use]
#[inline]
pub fn width(mut self, width: Length) -> Self {
self.container = self.container.width(width);
self
@ -76,6 +77,7 @@ where
/// Sets the height of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn height(mut self, height: Length) -> Self {
self.container = self.container.height(height);
self
@ -83,6 +85,7 @@ where
/// Sets the maximum width of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn max_width(mut self, max_width: f32) -> Self {
self.container = self.container.max_width(max_width);
self
@ -90,6 +93,7 @@ where
/// Sets the maximum height of the [`LayerContainer`] in pixels.
#[must_use]
#[inline]
pub fn max_height(mut self, max_height: f32) -> Self {
self.container = self.container.max_height(max_height);
self
@ -97,6 +101,7 @@ where
/// Sets the content alignment for the horizontal axis of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn align_x(mut self, alignment: Alignment) -> Self {
self.container = self.container.align_x(alignment);
self
@ -104,6 +109,7 @@ where
/// Sets the content alignment for the vertical axis of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn align_y(mut self, alignment: Alignment) -> Self {
self.container = self.container.align_y(alignment);
self
@ -111,6 +117,7 @@ where
/// Centers the contents in the horizontal axis of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn center_x(mut self, width: Length) -> Self {
self.container = self.container.center_x(width);
self
@ -118,6 +125,7 @@ where
/// Centers the contents in the vertical axis of the [`LayerContainer`].
#[must_use]
#[inline]
pub fn center_y(mut self, height: Length) -> Self {
self.container = self.container.center_y(height);
self
@ -125,6 +133,7 @@ where
/// Centers the contents in the horizontal and vertical axis of the [`Container`].
#[must_use]
#[inline]
pub fn center(mut self, length: Length) -> Self {
self.container = self.container.center(length);
self