From 31336b0b7dbf3beac4438284526725cfdd9ce005 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Sun, 19 Nov 2023 11:41:29 +0100 Subject: [PATCH] ui2: Do not enable 'stories' feature by default. This cuts down LLVM IR size from 3 million lines to 700k in debug build. This then leads to ~3s compile time in debug build (without incremental on ui itself), as opposed to 10.5s on main. --- crates/ui2/Cargo.toml | 2 +- crates/ui2/src/components/button.rs | 2 +- crates/ui2/src/components/keybinding.rs | 12 +++--------- crates/ui2/src/lib.rs | 6 ++++++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/ui2/Cargo.toml b/crates/ui2/Cargo.toml index 0a7de6299d1f0999df813ced30902c039615f662..efbec22bee4f65ad64d3225063ef7793a0bdec6c 100644 --- a/crates/ui2/Cargo.toml +++ b/crates/ui2/Cargo.toml @@ -18,5 +18,5 @@ theme2 = { path = "../theme2" } rand = "0.8" [features] -default = ["stories"] +default = [] stories = ["dep:itertools"] diff --git a/crates/ui2/src/components/button.rs b/crates/ui2/src/components/button.rs index de055bcd5c3f185a7c049cb58eaa64f523fec9e5..1bb611a86e7559b544d8a49731fe4c85d5128ead 100644 --- a/crates/ui2/src/components/button.rs +++ b/crates/ui2/src/components/button.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use gpui::{div, DefiniteLength, Hsla, MouseButton, StatefulInteractiveComponent, WindowContext}; +use gpui::{DefiniteLength, Hsla, MouseButton, StatefulInteractiveComponent, WindowContext}; use crate::prelude::*; use crate::{h_stack, Icon, IconButton, IconElement, Label, LineHeightStyle, TextColor}; diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs index 8da5273bf5f03afac68f898e3a52702568a92281..784886751f0e3cb74ac229ef2250d8d8f09cb749 100644 --- a/crates/ui2/src/components/keybinding.rs +++ b/crates/ui2/src/components/keybinding.rs @@ -80,18 +80,12 @@ pub use stories::*; #[cfg(feature = "stories")] mod stories { use super::*; - use crate::Story; - use gpui::{actions, Div, Render}; + pub use crate::KeyBinding; + use crate::{binding, Story}; + use gpui::{Div, Render}; use itertools::Itertools; - pub struct KeybindingStory; - actions!(NoAction); - - pub fn binding(key: &str) -> gpui::KeyBinding { - gpui::KeyBinding::new(key, NoAction {}, None) - } - impl Render for KeybindingStory { type Element = Div; diff --git a/crates/ui2/src/lib.rs b/crates/ui2/src/lib.rs index 149dcd3fd04bb8f21232fbe3ffd8deaa9d7bb440..25e9668a09cc0ae8b8cd60dd732d936c51eb08c1 100644 --- a/crates/ui2/src/lib.rs +++ b/crates/ui2/src/lib.rs @@ -24,6 +24,7 @@ mod to_extract; pub mod utils; pub use components::*; +use gpui::actions; pub use prelude::*; pub use static_data::*; pub use styled_ext::*; @@ -42,3 +43,8 @@ pub use crate::settings::*; mod story; #[cfg(feature = "stories")] pub use story::*; +actions!(NoAction); + +pub fn binding(key: &str) -> gpui::KeyBinding { + gpui::KeyBinding::new(key, NoAction {}, None) +}