diff --git a/Cargo.lock b/Cargo.lock index dfe8dc7529..86ae29e16b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1990,7 +1990,7 @@ dependencies = [ name = "collections" version = "0.1.0" dependencies = [ - "seahash", + "rustc-hash", ] [[package]] diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index dee285661a..09a8e859b4 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -1145,7 +1145,7 @@ impl CollabPanel { fn render_call_participant( &self, - user: Arc, + user: &Arc, peer_id: Option, is_pending: bool, cx: &mut ViewContext, @@ -2159,87 +2159,73 @@ impl CollabPanel { .id("scroll") .overflow_y_scroll() .track_scroll(&self.scroll_handle) - .children( - self.entries - .clone() - .into_iter() - .enumerate() - .map(|(ix, entry)| { - let is_selected = self.selection == Some(ix); - match entry { - ListEntry::Header(section) => { - let is_collapsed = - self.collapsed_sections.contains(§ion); - self.render_header(section, is_selected, is_collapsed, cx) - .into_any_element() - } - ListEntry::Contact { contact, calling } => self - .render_contact(&*contact, calling, is_selected, cx) - .into_any_element(), - ListEntry::ContactPlaceholder => self - .render_contact_placeholder(is_selected, cx) - .into_any_element(), - ListEntry::IncomingRequest(user) => self - .render_contact_request(user, true, is_selected, cx) - .into_any_element(), - ListEntry::OutgoingRequest(user) => self - .render_contact_request(user, false, is_selected, cx) - .into_any_element(), - ListEntry::Channel { - channel, - depth, - has_children, - } => self - .render_channel( - &*channel, - depth, - has_children, - is_selected, - ix, - cx, - ) - .into_any_element(), - ListEntry::ChannelEditor { depth } => { - self.render_channel_editor(depth, cx).into_any_element() - } - ListEntry::CallParticipant { - user, - peer_id, - is_pending, - } => self - .render_call_participant(user, peer_id, is_pending, cx) - .into_any_element(), - ListEntry::ParticipantProject { - project_id, - worktree_root_names, - host_user_id, - is_last, - } => self - .render_participant_project( - project_id, - &worktree_root_names, - host_user_id, - is_last, - cx, - ) - .into_any_element(), - ListEntry::ParticipantScreen { peer_id, is_last } => self - .render_participant_screen(peer_id, is_last, cx) - .into_any_element(), - ListEntry::ChannelNotes { channel_id } => { - self.render_channel_notes(channel_id, cx).into_any_element() - } - ListEntry::ChannelChat { channel_id } => { - self.render_channel_chat(channel_id, cx).into_any_element() - } - } - }), - ), + .children(self.entries.iter().enumerate().map(|(ix, entry)| { + let is_selected = self.selection == Some(ix); + match entry { + ListEntry::Header(section) => { + let is_collapsed = self.collapsed_sections.contains(section); + self.render_header(*section, is_selected, is_collapsed, cx) + .into_any_element() + } + ListEntry::Contact { contact, calling } => self + .render_contact(contact, *calling, is_selected, cx) + .into_any_element(), + ListEntry::ContactPlaceholder => self + .render_contact_placeholder(is_selected, cx) + .into_any_element(), + ListEntry::IncomingRequest(user) => self + .render_contact_request(user, true, is_selected, cx) + .into_any_element(), + ListEntry::OutgoingRequest(user) => self + .render_contact_request(user, false, is_selected, cx) + .into_any_element(), + ListEntry::Channel { + channel, + depth, + has_children, + } => self + .render_channel(channel, *depth, *has_children, is_selected, ix, cx) + .into_any_element(), + ListEntry::ChannelEditor { depth } => { + self.render_channel_editor(*depth, cx).into_any_element() + } + ListEntry::CallParticipant { + user, + peer_id, + is_pending, + } => self + .render_call_participant(user, *peer_id, *is_pending, cx) + .into_any_element(), + ListEntry::ParticipantProject { + project_id, + worktree_root_names, + host_user_id, + is_last, + } => self + .render_participant_project( + *project_id, + &worktree_root_names, + *host_user_id, + *is_last, + cx, + ) + .into_any_element(), + ListEntry::ParticipantScreen { peer_id, is_last } => self + .render_participant_screen(*peer_id, *is_last, cx) + .into_any_element(), + ListEntry::ChannelNotes { channel_id } => self + .render_channel_notes(*channel_id, cx) + .into_any_element(), + ListEntry::ChannelChat { channel_id } => { + self.render_channel_chat(*channel_id, cx).into_any_element() + } + } + })), ) } fn render_header( - &mut self, + &self, section: Section, is_selected: bool, is_collapsed: bool, @@ -2353,14 +2339,12 @@ impl CollabPanel { } fn render_contact( - &mut self, + &self, contact: &Contact, calling: bool, is_selected: bool, cx: &mut ViewContext, ) -> impl IntoElement { - enum ContactTooltip {} - let online = contact.online; let busy = contact.busy || calling; let user_id = contact.user.id; @@ -2426,8 +2410,8 @@ impl CollabPanel { } fn render_contact_request( - &mut self, - user: Arc, + &self, + user: &Arc, is_incoming: bool, is_selected: bool, cx: &mut ViewContext, @@ -2970,11 +2954,7 @@ impl CollabPanel { // .into_any() } - fn render_channel_editor( - &mut self, - depth: usize, - cx: &mut ViewContext, - ) -> impl IntoElement { + fn render_channel_editor(&self, depth: usize, cx: &mut ViewContext) -> impl IntoElement { let item = ListItem::new("channel-editor") .inset(false) .indent_level(depth) diff --git a/crates/collections/Cargo.toml b/crates/collections/Cargo.toml index dcbc642c4c..64db1161bb 100644 --- a/crates/collections/Cargo.toml +++ b/crates/collections/Cargo.toml @@ -9,7 +9,7 @@ path = "src/collections.rs" doctest = false [features] -test-support = ["seahash"] +test-support = [] [dependencies] -seahash = { version = "4.1", optional = true } +rustc-hash = "1.1" diff --git a/crates/collections/src/collections.rs b/crates/collections/src/collections.rs index bffa5c877a..7628349353 100644 --- a/crates/collections/src/collections.rs +++ b/crates/collections/src/collections.rs @@ -1,21 +1,8 @@ #[cfg(feature = "test-support")] -#[derive(Clone, Default)] -pub struct DeterministicState; +pub type HashMap = FxHashMap; #[cfg(feature = "test-support")] -impl std::hash::BuildHasher for DeterministicState { - type Hasher = seahash::SeaHasher; - - fn build_hasher(&self) -> Self::Hasher { - seahash::SeaHasher::new() - } -} - -#[cfg(feature = "test-support")] -pub type HashMap = std::collections::HashMap; - -#[cfg(feature = "test-support")] -pub type HashSet = std::collections::HashSet; +pub type HashSet = FxHashSet; #[cfg(not(feature = "test-support"))] pub type HashMap = std::collections::HashMap; @@ -23,6 +10,7 @@ pub type HashMap = std::collections::HashMap; #[cfg(not(feature = "test-support"))] pub type HashSet = std::collections::HashSet; +pub use rustc_hash::{FxHashMap, FxHashSet}; use std::any::TypeId; pub use std::collections::*; diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 0c6f7e3907..698e118fc3 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -1093,14 +1093,14 @@ mod tests { lsp.receive_notification::() .await, lsp::DidCloseTextDocumentParams { - text_document: lsp::TextDocumentIdentifier::new(buffer_2_uri.clone()), + text_document: lsp::TextDocumentIdentifier::new(buffer_1_uri.clone()), } ); assert_eq!( lsp.receive_notification::() .await, lsp::DidCloseTextDocumentParams { - text_document: lsp::TextDocumentIdentifier::new(buffer_1_uri.clone()), + text_document: lsp::TextDocumentIdentifier::new(buffer_2_uri.clone()), } ); @@ -1119,10 +1119,10 @@ mod tests { .await, lsp::DidOpenTextDocumentParams { text_document: lsp::TextDocumentItem::new( - buffer_2_uri.clone(), + buffer_1_uri.clone(), "plaintext".into(), 0, - "Goodbye".into() + "Hello world".into() ), } ); @@ -1131,10 +1131,10 @@ mod tests { .await, lsp::DidOpenTextDocumentParams { text_document: lsp::TextDocumentItem::new( - buffer_1_uri.clone(), + buffer_2_uri.clone(), "plaintext".into(), 0, - "Hello world".into() + "Goodbye".into() ), } ); diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index 88c5b8211d..0325b8d7f6 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -24,7 +24,7 @@ use crate::{ WindowContext, WindowHandle, WindowId, }; use anyhow::{anyhow, Result}; -use collections::{HashMap, HashSet, VecDeque}; +use collections::{FxHashMap, FxHashSet, VecDeque}; use futures::{channel::oneshot, future::LocalBoxFuture, Future}; use parking_lot::Mutex; use slotmap::SlotMap; @@ -191,24 +191,24 @@ pub struct AppContext { pub(crate) actions: Rc, pub(crate) active_drag: Option, pub(crate) active_tooltip: Option, - pub(crate) next_frame_callbacks: HashMap>, - pub(crate) frame_consumers: HashMap>, + pub(crate) next_frame_callbacks: FxHashMap>, + pub(crate) frame_consumers: FxHashMap>, pub(crate) background_executor: BackgroundExecutor, pub(crate) foreground_executor: ForegroundExecutor, pub(crate) svg_renderer: SvgRenderer, asset_source: Arc, pub(crate) image_cache: ImageCache, pub(crate) text_style_stack: Vec, - pub(crate) globals_by_type: HashMap>, + pub(crate) globals_by_type: FxHashMap>, pub(crate) entities: EntityMap, pub(crate) new_view_observers: SubscriberSet, pub(crate) windows: SlotMap>, pub(crate) keymap: Arc>, pub(crate) global_action_listeners: - HashMap>>, + FxHashMap>>, pending_effects: VecDeque, - pub(crate) pending_notifications: HashSet, - pub(crate) pending_global_notifications: HashSet, + pub(crate) pending_notifications: FxHashSet, + pub(crate) pending_global_notifications: FxHashSet, pub(crate) observers: SubscriberSet, // TypeId is the type of the event that the listener callback expects pub(crate) event_listeners: SubscriberSet, @@ -253,23 +253,23 @@ impl AppContext { pending_updates: 0, active_drag: None, active_tooltip: None, - next_frame_callbacks: HashMap::default(), - frame_consumers: HashMap::default(), + next_frame_callbacks: FxHashMap::default(), + frame_consumers: FxHashMap::default(), background_executor: executor, foreground_executor, svg_renderer: SvgRenderer::new(asset_source.clone()), asset_source, image_cache: ImageCache::new(http_client), text_style_stack: Vec::new(), - globals_by_type: HashMap::default(), + globals_by_type: FxHashMap::default(), entities, new_view_observers: SubscriberSet::new(), windows: SlotMap::with_key(), keymap: Arc::new(Mutex::new(Keymap::default())), - global_action_listeners: HashMap::default(), + global_action_listeners: FxHashMap::default(), pending_effects: VecDeque::new(), - pending_notifications: HashSet::default(), - pending_global_notifications: HashSet::default(), + pending_notifications: FxHashSet::default(), + pending_global_notifications: FxHashSet::default(), observers: SubscriberSet::new(), event_listeners: SubscriberSet::new(), release_listeners: SubscriberSet::new(), diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index 7c365d8734..b0ccc00d00 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -26,7 +26,7 @@ const TOOLTIP_DELAY: Duration = Duration::from_millis(500); pub struct GroupStyle { pub group: SharedString, - pub style: StyleRefinement, + pub style: Box, } pub trait InteractiveElement: Sized + Element { @@ -61,7 +61,7 @@ pub trait InteractiveElement: Sized + Element { } fn hover(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self { - self.interactivity().hover_style = f(StyleRefinement::default()); + self.interactivity().hover_style = Some(Box::new(f(StyleRefinement::default()))); self } @@ -72,7 +72,7 @@ pub trait InteractiveElement: Sized + Element { ) -> Self { self.interactivity().group_hover_style = Some(GroupStyle { group: group_name.into(), - style: f(StyleRefinement::default()), + style: Box::new(f(StyleRefinement::default())), }); self } @@ -319,7 +319,7 @@ pub trait InteractiveElement: Sized + Element { TypeId::of::(), GroupStyle { group: group_name.into(), - style: f(StyleRefinement::default()), + style: Box::new(f(StyleRefinement::default())), }, )); self @@ -370,7 +370,7 @@ pub trait StatefulInteractiveElement: InteractiveElement { where Self: Sized, { - self.interactivity().active_style = f(StyleRefinement::default()); + self.interactivity().active_style = Some(Box::new(f(StyleRefinement::default()))); self } @@ -384,7 +384,7 @@ pub trait StatefulInteractiveElement: InteractiveElement { { self.interactivity().group_active_style = Some(GroupStyle { group: group_name.into(), - style: f(StyleRefinement::default()), + style: Box::new(f(StyleRefinement::default())), }); self } @@ -446,7 +446,7 @@ pub trait FocusableElement: InteractiveElement { where Self: Sized, { - self.interactivity().focus_style = f(StyleRefinement::default()); + self.interactivity().focus_style = Some(Box::new(f(StyleRefinement::default()))); self } @@ -454,7 +454,7 @@ pub trait FocusableElement: InteractiveElement { where Self: Sized, { - self.interactivity().in_focus_style = f(StyleRefinement::default()); + self.interactivity().in_focus_style = Some(Box::new(f(StyleRefinement::default()))); self } @@ -532,7 +532,7 @@ pub trait FocusableElement: InteractiveElement { } } -pub type FocusListeners = SmallVec<[FocusListener; 2]>; +pub type FocusListeners = Vec; pub type FocusListener = Box; @@ -602,8 +602,7 @@ impl Element for Div { cx: &mut WindowContext, ) -> (LayoutId, Self::State) { let mut child_layout_ids = SmallVec::new(); - let mut interactivity = mem::take(&mut self.interactivity); - let (layout_id, interactive_state) = interactivity.layout( + let (layout_id, interactive_state) = self.interactivity.layout( element_state.map(|s| s.interactive_state), cx, |style, cx| { @@ -617,7 +616,6 @@ impl Element for Div { }) }, ); - self.interactivity = interactivity; ( layout_id, DivState { @@ -712,7 +710,7 @@ impl IntoElement for Div { } pub struct DivState { - child_layout_ids: SmallVec<[LayoutId; 4]>, + child_layout_ids: SmallVec<[LayoutId; 2]>, interactive_state: InteractiveElementState, } @@ -730,24 +728,24 @@ pub struct Interactivity { pub scroll_handle: Option, pub focus_listeners: FocusListeners, pub group: Option, - pub base_style: StyleRefinement, - pub focus_style: StyleRefinement, - pub in_focus_style: StyleRefinement, - pub hover_style: StyleRefinement, + pub base_style: Box, + pub focus_style: Option>, + pub in_focus_style: Option>, + pub hover_style: Option>, pub group_hover_style: Option, - pub active_style: StyleRefinement, + pub active_style: Option>, pub group_active_style: Option, - pub drag_over_styles: SmallVec<[(TypeId, StyleRefinement); 2]>, - pub group_drag_over_styles: SmallVec<[(TypeId, GroupStyle); 2]>, - pub mouse_down_listeners: SmallVec<[MouseDownListener; 2]>, - pub mouse_up_listeners: SmallVec<[MouseUpListener; 2]>, - pub mouse_move_listeners: SmallVec<[MouseMoveListener; 2]>, - pub scroll_wheel_listeners: SmallVec<[ScrollWheelListener; 2]>, - pub key_down_listeners: SmallVec<[KeyDownListener; 2]>, - pub key_up_listeners: SmallVec<[KeyUpListener; 2]>, - pub action_listeners: SmallVec<[(TypeId, ActionListener); 8]>, - pub drop_listeners: SmallVec<[(TypeId, Box); 2]>, - pub click_listeners: SmallVec<[ClickListener; 2]>, + pub drag_over_styles: Vec<(TypeId, StyleRefinement)>, + pub group_drag_over_styles: Vec<(TypeId, GroupStyle)>, + pub mouse_down_listeners: Vec, + pub mouse_up_listeners: Vec, + pub mouse_move_listeners: Vec, + pub scroll_wheel_listeners: Vec, + pub key_down_listeners: Vec, + pub key_up_listeners: Vec, + pub action_listeners: Vec<(TypeId, ActionListener)>, + pub drop_listeners: Vec<(TypeId, Box)>, + pub click_listeners: Vec, pub drag_listener: Option, pub hover_listener: Option>, pub tooltip_builder: Option, @@ -1177,12 +1175,16 @@ impl Interactivity { style.refine(&self.base_style); if let Some(focus_handle) = self.tracked_focus_handle.as_ref() { - if focus_handle.within_focused(cx) { - style.refine(&self.in_focus_style); + if let Some(in_focus_style) = self.in_focus_style.as_ref() { + if focus_handle.within_focused(cx) { + style.refine(in_focus_style); + } } - if focus_handle.is_focused(cx) { - style.refine(&self.focus_style); + if let Some(focus_style) = self.focus_style.as_ref() { + if focus_handle.is_focused(cx) { + style.refine(focus_style); + } } } @@ -1197,13 +1199,13 @@ impl Interactivity { } } } - if self.hover_style.is_some() { + if let Some(hover_style) = self.hover_style.as_ref() { if bounds .intersect(&cx.content_mask().bounds) .contains(&mouse_position) && cx.was_top_layer(&mouse_position, cx.stacking_order()) { - style.refine(&self.hover_style); + style.refine(hover_style); } } @@ -1239,8 +1241,10 @@ impl Interactivity { } } - if clicked_state.element { - style.refine(&self.active_style) + if let Some(active_style) = self.active_style.as_ref() { + if clicked_state.element { + style.refine(active_style) + } } style @@ -1255,27 +1259,27 @@ impl Default for Interactivity { focusable: false, tracked_focus_handle: None, scroll_handle: None, - focus_listeners: SmallVec::default(), + focus_listeners: Vec::default(), // scroll_offset: Point::default(), group: None, - base_style: StyleRefinement::default(), - focus_style: StyleRefinement::default(), - in_focus_style: StyleRefinement::default(), - hover_style: StyleRefinement::default(), + base_style: Box::new(StyleRefinement::default()), + focus_style: None, + in_focus_style: None, + hover_style: None, group_hover_style: None, - active_style: StyleRefinement::default(), + active_style: None, group_active_style: None, - drag_over_styles: SmallVec::new(), - group_drag_over_styles: SmallVec::new(), - mouse_down_listeners: SmallVec::new(), - mouse_up_listeners: SmallVec::new(), - mouse_move_listeners: SmallVec::new(), - scroll_wheel_listeners: SmallVec::new(), - key_down_listeners: SmallVec::new(), - key_up_listeners: SmallVec::new(), - action_listeners: SmallVec::new(), - drop_listeners: SmallVec::new(), - click_listeners: SmallVec::new(), + drag_over_styles: Vec::new(), + group_drag_over_styles: Vec::new(), + mouse_down_listeners: Vec::new(), + mouse_up_listeners: Vec::new(), + mouse_move_listeners: Vec::new(), + scroll_wheel_listeners: Vec::new(), + key_down_listeners: Vec::new(), + key_up_listeners: Vec::new(), + action_listeners: Vec::new(), + drop_listeners: Vec::new(), + click_listeners: Vec::new(), drag_listener: None, hover_listener: None, tooltip_builder: None, diff --git a/crates/gpui2/src/elements/uniform_list.rs b/crates/gpui2/src/elements/uniform_list.rs index f198eff77c..d27b3bdb77 100644 --- a/crates/gpui2/src/elements/uniform_list.rs +++ b/crates/gpui2/src/elements/uniform_list.rs @@ -41,7 +41,7 @@ where render_items: Box::new(render_range), interactivity: Interactivity { element_id: Some(id.into()), - base_style, + base_style: Box::new(base_style), ..Default::default() }, scroll_handle: None, diff --git a/crates/gpui2/src/key_dispatch.rs b/crates/gpui2/src/key_dispatch.rs index a1571c09f2..a44987aa39 100644 --- a/crates/gpui2/src/key_dispatch.rs +++ b/crates/gpui2/src/key_dispatch.rs @@ -26,8 +26,8 @@ pub(crate) struct DispatchTree { #[derive(Default)] pub(crate) struct DispatchNode { - pub key_listeners: SmallVec<[KeyListener; 2]>, - pub action_listeners: SmallVec<[DispatchActionListener; 16]>, + pub key_listeners: Vec, + pub action_listeners: Vec, pub context: Option, parent: Option, } diff --git a/crates/gpui2/src/keymap/context.rs b/crates/gpui2/src/keymap/context.rs index 057de5f71f..fb90a0c764 100644 --- a/crates/gpui2/src/keymap/context.rs +++ b/crates/gpui2/src/keymap/context.rs @@ -4,7 +4,7 @@ use smallvec::SmallVec; use std::fmt; #[derive(Clone, Default, Eq, PartialEq, Hash)] -pub struct KeyContext(SmallVec<[ContextEntry; 8]>); +pub struct KeyContext(SmallVec<[ContextEntry; 1]>); #[derive(Clone, Debug, Eq, PartialEq, Hash)] struct ContextEntry { diff --git a/crates/gpui2/src/platform/mac/metal_atlas.rs b/crates/gpui2/src/platform/mac/metal_atlas.rs index 777d97b37f..2110815d9f 100644 --- a/crates/gpui2/src/platform/mac/metal_atlas.rs +++ b/crates/gpui2/src/platform/mac/metal_atlas.rs @@ -3,7 +3,7 @@ use crate::{ Point, Size, }; use anyhow::Result; -use collections::HashMap; +use collections::FxHashMap; use derive_more::{Deref, DerefMut}; use etagere::BucketedAtlasAllocator; use metal::Device; @@ -53,7 +53,7 @@ struct MetalAtlasState { monochrome_textures: Vec, polychrome_textures: Vec, path_textures: Vec, - tiles_by_key: HashMap, + tiles_by_key: FxHashMap, } impl PlatformAtlas for MetalAtlas { diff --git a/crates/gpui2/src/style.rs b/crates/gpui2/src/style.rs index 5c511b41a4..04f247d076 100644 --- a/crates/gpui2/src/style.rs +++ b/crates/gpui2/src/style.rs @@ -608,14 +608,14 @@ mod tests { ( 1..2, HighlightStyle { - color: Some(blue()), + color: Some(green()), ..Default::default() } ), ( 2..3, HighlightStyle { - color: Some(blue()), + color: Some(green()), font_style: Some(FontStyle::Italic), ..Default::default() } diff --git a/crates/gpui2/src/taffy.rs b/crates/gpui2/src/taffy.rs index b4fc6c3abe..88fb8e8814 100644 --- a/crates/gpui2/src/taffy.rs +++ b/crates/gpui2/src/taffy.rs @@ -2,7 +2,7 @@ use crate::{ AbsoluteLength, Bounds, DefiniteLength, Edges, Length, Pixels, Point, Size, Style, WindowContext, }; -use collections::{HashMap, HashSet}; +use collections::{FxHashMap, FxHashSet}; use smallvec::SmallVec; use std::fmt::Debug; use taffy::{ @@ -14,10 +14,10 @@ use taffy::{ pub struct TaffyLayoutEngine { taffy: Taffy, - children_to_parents: HashMap, - absolute_layout_bounds: HashMap>, - computed_layouts: HashSet, - nodes_to_measure: HashMap< + children_to_parents: FxHashMap, + absolute_layout_bounds: FxHashMap>, + computed_layouts: FxHashSet, + nodes_to_measure: FxHashMap< LayoutId, Box< dyn FnMut( @@ -36,10 +36,10 @@ impl TaffyLayoutEngine { pub fn new() -> Self { TaffyLayoutEngine { taffy: Taffy::new(), - children_to_parents: HashMap::default(), - absolute_layout_bounds: HashMap::default(), - computed_layouts: HashSet::default(), - nodes_to_measure: HashMap::default(), + children_to_parents: FxHashMap::default(), + absolute_layout_bounds: FxHashMap::default(), + computed_layouts: FxHashSet::default(), + nodes_to_measure: FxHashMap::default(), } } diff --git a/crates/gpui2/src/text_system.rs b/crates/gpui2/src/text_system.rs index b3f17bd057..ad82c41082 100644 --- a/crates/gpui2/src/text_system.rs +++ b/crates/gpui2/src/text_system.rs @@ -13,7 +13,7 @@ use crate::{ UnderlineStyle, }; use anyhow::anyhow; -use collections::HashMap; +use collections::FxHashMap; use core::fmt; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use smallvec::SmallVec; @@ -37,10 +37,10 @@ pub const SUBPIXEL_VARIANTS: u8 = 4; pub struct TextSystem { line_layout_cache: Arc, platform_text_system: Arc, - font_ids_by_font: RwLock>, - font_metrics: RwLock>, - raster_bounds: RwLock>>, - wrapper_pool: Mutex>>, + font_ids_by_font: RwLock>, + font_metrics: RwLock>, + raster_bounds: RwLock>>, + wrapper_pool: Mutex>>, font_runs_pool: Mutex>>, } diff --git a/crates/gpui2/src/text_system/line_layout.rs b/crates/gpui2/src/text_system/line_layout.rs index 2370aca83b..6506d7794c 100644 --- a/crates/gpui2/src/text_system/line_layout.rs +++ b/crates/gpui2/src/text_system/line_layout.rs @@ -1,9 +1,9 @@ use crate::{px, FontId, GlyphId, Pixels, PlatformTextSystem, Point, Size}; +use collections::FxHashMap; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use smallvec::SmallVec; use std::{ borrow::Borrow, - collections::HashMap, hash::{Hash, Hasher}, sync::Arc, }; @@ -236,10 +236,10 @@ impl WrappedLineLayout { } pub(crate) struct LineLayoutCache { - previous_frame: Mutex>>, - current_frame: RwLock>>, - previous_frame_wrapped: Mutex>>, - current_frame_wrapped: RwLock>>, + previous_frame: Mutex>>, + current_frame: RwLock>>, + previous_frame_wrapped: Mutex>>, + current_frame_wrapped: RwLock>>, platform_text_system: Arc, }