diff --git a/build-config.yaml b/build-config.yaml index 4c26b461dc9..31c47bb6aa6 100644 --- a/build-config.yaml +++ b/build-config.yaml @@ -1,6 +1,6 @@ # Options intended to be common for all developers. -wasm-size-limit: 15.25 MiB +wasm-size-limit: 14.9 MiB required-versions: cargo-watch: ^8.1.1 diff --git a/lib/rust/frp/src/stream.rs b/lib/rust/frp/src/stream.rs index f05cdd259bf..5e23385ae09 100644 --- a/lib/rust/frp/src/stream.rs +++ b/lib/rust/frp/src/stream.rs @@ -84,7 +84,7 @@ impl Display for DisabledCallStack { /// Label of the output type of this FRP node. Used mainly for debugging purposes. pub trait HasOutputTypeLabel { /// Output type label of this object. - fn output_type_label(&self) -> String; + fn output_type_label(&self) -> Label; } @@ -659,24 +659,25 @@ where Def: InputBehaviors } } -// FIXME code quality below: impl HasOutputTypeLabel for Node where Def: HasOutputStatic + InputBehaviors { - fn output_type_label(&self) -> String { - let label = type_name::().to_string(); - let label = label.split(|c| c == '<').collect::>()[0]; - let mut label = label.split(|c| c == ':').collect::>(); - label.reverse(); - let mut label = label[0]; - let sfx = "Data"; - if label.ends_with(sfx) { - label = &label[0..label.len() - sfx.len()]; - } - label.into() + fn output_type_label(&self) -> Label { + type_name_to_output_label(type_name::()) } } +// The label transformation logic is a separate non-generic function, so that it can be compiled +// only once for all node types. This has a noticeable impact on compilation time. +// For more details see https://github.com/enso-org/enso/pull/3848 +#[inline(never)] +fn type_name_to_output_label(typename: &'static str) -> Label { + let label = typename.split('<').next().unwrap_or(typename); + let label = label.rsplit(':').next().unwrap_or(label); + let label = label.strip_suffix("Data").unwrap_or(label); + label +} + // === InputBehaviors ===