1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 07:03:14 -04:00

Reduce binary size with more inlining and less monomorphization

5%=150kB savings on egui_demo_app wasm
This commit is contained in:
Emil Ernerfeldt
2021-04-24 09:54:11 +02:00
parent f38f68318d
commit 0f112db550
4 changed files with 97 additions and 18 deletions

View File

@@ -45,6 +45,7 @@ impl Align {
}
/// Convert `Min => 0.0`, `Center => 0.5` or `Max => 1.0`.
#[inline(always)]
pub fn to_factor(&self) -> f32 {
match self {
Self::Min => 0.0,
@@ -54,6 +55,7 @@ impl Align {
}
/// Convert `Min => -1.0`, `Center => 0.0` or `Max => 1.0`.
#[inline(always)]
pub fn to_sign(&self) -> f32 {
match self {
Self::Min => -1.0,
@@ -64,6 +66,7 @@ impl Align {
}
impl Default for Align {
#[inline(always)]
fn default() -> Align {
Align::Min
}
@@ -90,9 +93,12 @@ impl Align2 {
}
impl Align2 {
#[inline(always)]
pub fn x(self) -> Align {
self.0[0]
}
#[inline(always)]
pub fn y(self) -> Align {
self.0[1]
}