Use Fx* variants of HashMap and HashSet everywhere in Zed (#7481)

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2024-02-07 09:45:37 +02:00 committed by GitHub
parent 7939673a7d
commit eb236302c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 96 additions and 102 deletions

4
Cargo.lock generated
View File

@ -7530,6 +7530,7 @@ name = "sqlez"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collections",
"futures 0.3.28", "futures 0.3.28",
"indoc", "indoc",
"lazy_static", "lazy_static",
@ -8105,6 +8106,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"alacritty_terminal", "alacritty_terminal",
"anyhow", "anyhow",
"collections",
"db", "db",
"dirs 4.0.0", "dirs 4.0.0",
"futures 0.3.28", "futures 0.3.28",
@ -8200,6 +8202,7 @@ name = "theme"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collections",
"color", "color",
"derive_more", "derive_more",
"fs", "fs",
@ -9343,6 +9346,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"backtrace", "backtrace",
"collections",
"dirs 3.0.2", "dirs 3.0.2",
"futures 0.3.28", "futures 0.3.28",
"git2", "git2",

View File

@ -5,13 +5,13 @@ use client::{
user::{User, UserStore}, user::{User, UserStore},
Client, Subscription, TypedEnvelope, UserId, Client, Subscription, TypedEnvelope, UserId,
}; };
use collections::HashSet;
use futures::lock::Mutex; use futures::lock::Mutex;
use gpui::{ use gpui::{
AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel, AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel,
}; };
use rand::prelude::*; use rand::prelude::*;
use std::{ use std::{
collections::HashSet,
ops::{ControlFlow, Range}, ops::{ControlFlow, Range},
sync::Arc, sync::Arc,
}; };

View File

@ -10,6 +10,7 @@ use async_tungstenite::tungstenite::{
error::Error as WebsocketError, error::Error as WebsocketError,
http::{Request, StatusCode}, http::{Request, StatusCode},
}; };
use collections::HashMap;
use futures::{ use futures::{
channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt, channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamExt,
TryFutureExt as _, TryStreamExt, TryFutureExt as _, TryStreamExt,
@ -29,7 +30,6 @@ use serde_json;
use settings::{Settings, SettingsStore}; use settings::{Settings, SettingsStore};
use std::{ use std::{
any::TypeId, any::TypeId,
collections::HashMap,
convert::TryFrom, convert::TryFrom,
fmt::Write as _, fmt::Write as _,
future::Future, future::Future,

View File

@ -23,7 +23,7 @@ use crate::{
TextSystem, View, ViewContext, Window, WindowContext, WindowHandle, WindowId, TextSystem, View, ViewContext, Window, WindowContext, WindowHandle, WindowId,
}; };
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use collections::{FxHashMap, FxHashSet, VecDeque}; use collections::{HashMap, HashSet, VecDeque};
use futures::{channel::oneshot, future::LocalBoxFuture, Future}; use futures::{channel::oneshot, future::LocalBoxFuture, Future};
use slotmap::SlotMap; use slotmap::SlotMap;
@ -212,24 +212,24 @@ pub struct AppContext {
pending_updates: usize, pending_updates: usize,
pub(crate) actions: Rc<ActionRegistry>, pub(crate) actions: Rc<ActionRegistry>,
pub(crate) active_drag: Option<AnyDrag>, pub(crate) active_drag: Option<AnyDrag>,
pub(crate) next_frame_callbacks: FxHashMap<DisplayId, Vec<FrameCallback>>, pub(crate) next_frame_callbacks: HashMap<DisplayId, Vec<FrameCallback>>,
pub(crate) frame_consumers: FxHashMap<DisplayId, Task<()>>, pub(crate) frame_consumers: HashMap<DisplayId, Task<()>>,
pub(crate) background_executor: BackgroundExecutor, pub(crate) background_executor: BackgroundExecutor,
pub(crate) foreground_executor: ForegroundExecutor, pub(crate) foreground_executor: ForegroundExecutor,
pub(crate) svg_renderer: SvgRenderer, pub(crate) svg_renderer: SvgRenderer,
asset_source: Arc<dyn AssetSource>, asset_source: Arc<dyn AssetSource>,
pub(crate) image_cache: ImageCache, pub(crate) image_cache: ImageCache,
pub(crate) text_style_stack: Vec<TextStyleRefinement>, pub(crate) text_style_stack: Vec<TextStyleRefinement>,
pub(crate) globals_by_type: FxHashMap<TypeId, Box<dyn Any>>, pub(crate) globals_by_type: HashMap<TypeId, Box<dyn Any>>,
pub(crate) entities: EntityMap, pub(crate) entities: EntityMap,
pub(crate) new_view_observers: SubscriberSet<TypeId, NewViewListener>, pub(crate) new_view_observers: SubscriberSet<TypeId, NewViewListener>,
pub(crate) windows: SlotMap<WindowId, Option<Window>>, pub(crate) windows: SlotMap<WindowId, Option<Window>>,
pub(crate) keymap: Rc<RefCell<Keymap>>, pub(crate) keymap: Rc<RefCell<Keymap>>,
pub(crate) global_action_listeners: pub(crate) global_action_listeners:
FxHashMap<TypeId, Vec<Rc<dyn Fn(&dyn Any, DispatchPhase, &mut Self)>>>, HashMap<TypeId, Vec<Rc<dyn Fn(&dyn Any, DispatchPhase, &mut Self)>>>,
pending_effects: VecDeque<Effect>, pending_effects: VecDeque<Effect>,
pub(crate) pending_notifications: FxHashSet<EntityId>, pub(crate) pending_notifications: HashSet<EntityId>,
pub(crate) pending_global_notifications: FxHashSet<TypeId>, pub(crate) pending_global_notifications: HashSet<TypeId>,
pub(crate) observers: SubscriberSet<EntityId, Handler>, pub(crate) observers: SubscriberSet<EntityId, Handler>,
// TypeId is the type of the event that the listener callback expects // TypeId is the type of the event that the listener callback expects
pub(crate) event_listeners: SubscriberSet<EntityId, (TypeId, Listener)>, pub(crate) event_listeners: SubscriberSet<EntityId, (TypeId, Listener)>,
@ -274,23 +274,23 @@ impl AppContext {
flushing_effects: false, flushing_effects: false,
pending_updates: 0, pending_updates: 0,
active_drag: None, active_drag: None,
next_frame_callbacks: FxHashMap::default(), next_frame_callbacks: HashMap::default(),
frame_consumers: FxHashMap::default(), frame_consumers: HashMap::default(),
background_executor: executor, background_executor: executor,
foreground_executor, foreground_executor,
svg_renderer: SvgRenderer::new(asset_source.clone()), svg_renderer: SvgRenderer::new(asset_source.clone()),
asset_source, asset_source,
image_cache: ImageCache::new(http_client), image_cache: ImageCache::new(http_client),
text_style_stack: Vec::new(), text_style_stack: Vec::new(),
globals_by_type: FxHashMap::default(), globals_by_type: HashMap::default(),
entities, entities,
new_view_observers: SubscriberSet::new(), new_view_observers: SubscriberSet::new(),
windows: SlotMap::with_key(), windows: SlotMap::with_key(),
keymap: Rc::new(RefCell::new(Keymap::default())), keymap: Rc::new(RefCell::new(Keymap::default())),
global_action_listeners: FxHashMap::default(), global_action_listeners: HashMap::default(),
pending_effects: VecDeque::new(), pending_effects: VecDeque::new(),
pending_notifications: FxHashSet::default(), pending_notifications: HashSet::default(),
pending_global_notifications: FxHashSet::default(), pending_global_notifications: HashSet::default(),
observers: SubscriberSet::new(), observers: SubscriberSet::new(),
event_listeners: SubscriberSet::new(), event_listeners: SubscriberSet::new(),
release_listeners: SubscriberSet::new(), release_listeners: SubscriberSet::new(),

View File

@ -53,7 +53,7 @@ use crate::{
Action, ActionRegistry, DispatchPhase, ElementContext, EntityId, FocusId, KeyBinding, Action, ActionRegistry, DispatchPhase, ElementContext, EntityId, FocusId, KeyBinding,
KeyContext, Keymap, KeymatchResult, Keystroke, KeystrokeMatcher, WindowContext, KeyContext, Keymap, KeymatchResult, Keystroke, KeystrokeMatcher, WindowContext,
}; };
use collections::FxHashMap; use collections::HashMap;
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
use std::{ use std::{
any::{Any, TypeId}, any::{Any, TypeId},
@ -69,9 +69,9 @@ pub(crate) struct DispatchTree {
node_stack: Vec<DispatchNodeId>, node_stack: Vec<DispatchNodeId>,
pub(crate) context_stack: Vec<KeyContext>, pub(crate) context_stack: Vec<KeyContext>,
nodes: Vec<DispatchNode>, nodes: Vec<DispatchNode>,
focusable_node_ids: FxHashMap<FocusId, DispatchNodeId>, focusable_node_ids: HashMap<FocusId, DispatchNodeId>,
view_node_ids: FxHashMap<EntityId, DispatchNodeId>, view_node_ids: HashMap<EntityId, DispatchNodeId>,
keystroke_matchers: FxHashMap<SmallVec<[KeyContext; 4]>, KeystrokeMatcher>, keystroke_matchers: HashMap<SmallVec<[KeyContext; 4]>, KeystrokeMatcher>,
keymap: Rc<RefCell<Keymap>>, keymap: Rc<RefCell<Keymap>>,
action_registry: Rc<ActionRegistry>, action_registry: Rc<ActionRegistry>,
} }
@ -100,9 +100,9 @@ impl DispatchTree {
node_stack: Vec::new(), node_stack: Vec::new(),
context_stack: Vec::new(), context_stack: Vec::new(),
nodes: Vec::new(), nodes: Vec::new(),
focusable_node_ids: FxHashMap::default(), focusable_node_ids: HashMap::default(),
view_node_ids: FxHashMap::default(), view_node_ids: HashMap::default(),
keystroke_matchers: FxHashMap::default(), keystroke_matchers: HashMap::default(),
keymap, keymap,
action_registry, action_registry,
} }

View File

@ -7,12 +7,9 @@ pub use context::*;
pub(crate) use matcher::*; pub(crate) use matcher::*;
use crate::{Action, Keystroke, NoAction}; use crate::{Action, Keystroke, NoAction};
use collections::HashSet; use collections::{HashMap, HashSet};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{ use std::any::{Any, TypeId};
any::{Any, TypeId},
collections::HashMap,
};
/// An opaque identifier of which version of the keymap is currently active. /// An opaque identifier of which version of the keymap is currently active.
/// The keymap's version is changed whenever bindings are added or removed. /// The keymap's version is changed whenever bindings are added or removed.

View File

@ -3,7 +3,7 @@ use crate::{
Point, Size, Point, Size,
}; };
use anyhow::Result; use anyhow::Result;
use collections::FxHashMap; use collections::HashMap;
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use etagere::BucketedAtlasAllocator; use etagere::BucketedAtlasAllocator;
use metal::Device; use metal::Device;
@ -53,7 +53,7 @@ struct MetalAtlasState {
monochrome_textures: Vec<MetalAtlasTexture>, monochrome_textures: Vec<MetalAtlasTexture>,
polychrome_textures: Vec<MetalAtlasTexture>, polychrome_textures: Vec<MetalAtlasTexture>,
path_textures: Vec<MetalAtlasTexture>, path_textures: Vec<MetalAtlasTexture>,
tiles_by_key: FxHashMap<AtlasKey, AtlasTile>, tiles_by_key: HashMap<AtlasKey, AtlasTile>,
} }
impl PlatformAtlas for MetalAtlas { impl PlatformAtlas for MetalAtlas {

View File

@ -2,7 +2,7 @@ use crate::{
point, AtlasTextureId, AtlasTile, Bounds, ContentMask, Corners, Edges, EntityId, Hsla, Pixels, point, AtlasTextureId, AtlasTile, Bounds, ContentMask, Corners, Edges, EntityId, Hsla, Pixels,
Point, ScaledPixels, StackingOrder, Point, ScaledPixels, StackingOrder,
}; };
use collections::{BTreeMap, FxHashSet}; use collections::{BTreeMap, HashSet};
use std::{fmt::Debug, iter::Peekable, slice}; use std::{fmt::Debug, iter::Peekable, slice};
// Exported to metal // Exported to metal
@ -159,7 +159,7 @@ impl Scene {
layer_id layer_id
} }
pub fn reuse_views(&mut self, views: &FxHashSet<EntityId>, prev_scene: &mut Self) { pub fn reuse_views(&mut self, views: &HashSet<EntityId>, prev_scene: &mut Self) {
for shadow in prev_scene.shadows.drain(..) { for shadow in prev_scene.shadows.drain(..) {
if views.contains(&shadow.view_id.into()) { if views.contains(&shadow.view_id.into()) {
let order = &prev_scene.orders_by_layer[&shadow.layer_id]; let order = &prev_scene.orders_by_layer[&shadow.layer_id];

View File

@ -2,7 +2,7 @@ use crate::{
AbsoluteLength, Bounds, DefiniteLength, Edges, Length, Pixels, Point, Size, Style, AbsoluteLength, Bounds, DefiniteLength, Edges, Length, Pixels, Point, Size, Style,
WindowContext, WindowContext,
}; };
use collections::{FxHashMap, FxHashSet}; use collections::{HashMap, HashSet};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::Debug; use std::fmt::Debug;
use taffy::{ use taffy::{
@ -17,11 +17,11 @@ type NodeMeasureFn =
pub struct TaffyLayoutEngine { pub struct TaffyLayoutEngine {
taffy: Taffy, taffy: Taffy,
styles: FxHashMap<LayoutId, Style>, styles: HashMap<LayoutId, Style>,
children_to_parents: FxHashMap<LayoutId, LayoutId>, children_to_parents: HashMap<LayoutId, LayoutId>,
absolute_layout_bounds: FxHashMap<LayoutId, Bounds<Pixels>>, absolute_layout_bounds: HashMap<LayoutId, Bounds<Pixels>>,
computed_layouts: FxHashSet<LayoutId>, computed_layouts: HashSet<LayoutId>,
nodes_to_measure: FxHashMap<LayoutId, NodeMeasureFn>, nodes_to_measure: HashMap<LayoutId, NodeMeasureFn>,
} }
static EXPECT_MESSAGE: &str = "we should avoid taffy layout errors by construction if possible"; static EXPECT_MESSAGE: &str = "we should avoid taffy layout errors by construction if possible";
@ -30,11 +30,11 @@ impl TaffyLayoutEngine {
pub fn new() -> Self { pub fn new() -> Self {
TaffyLayoutEngine { TaffyLayoutEngine {
taffy: Taffy::new(), taffy: Taffy::new(),
styles: FxHashMap::default(), styles: HashMap::default(),
children_to_parents: FxHashMap::default(), children_to_parents: HashMap::default(),
absolute_layout_bounds: FxHashMap::default(), absolute_layout_bounds: HashMap::default(),
computed_layouts: FxHashSet::default(), computed_layouts: HashSet::default(),
nodes_to_measure: FxHashMap::default(), nodes_to_measure: HashMap::default(),
} }
} }

View File

@ -13,7 +13,7 @@ use crate::{
SharedString, Size, UnderlineStyle, SharedString, Size, UnderlineStyle,
}; };
use anyhow::anyhow; use anyhow::anyhow;
use collections::{BTreeSet, FxHashMap, FxHashSet}; use collections::{BTreeSet, HashMap, HashSet};
use core::fmt; use core::fmt;
use derive_more::Deref; use derive_more::Deref;
use itertools::Itertools; use itertools::Itertools;
@ -42,10 +42,10 @@ pub(crate) const SUBPIXEL_VARIANTS: u8 = 4;
/// The GPUI text rendering sub system. /// The GPUI text rendering sub system.
pub struct TextSystem { pub struct TextSystem {
platform_text_system: Arc<dyn PlatformTextSystem>, platform_text_system: Arc<dyn PlatformTextSystem>,
font_ids_by_font: RwLock<FxHashMap<Font, Result<FontId>>>, font_ids_by_font: RwLock<HashMap<Font, Result<FontId>>>,
font_metrics: RwLock<FxHashMap<FontId, FontMetrics>>, font_metrics: RwLock<HashMap<FontId, FontMetrics>>,
raster_bounds: RwLock<FxHashMap<RenderGlyphParams, Bounds<DevicePixels>>>, raster_bounds: RwLock<HashMap<RenderGlyphParams, Bounds<DevicePixels>>>,
wrapper_pool: Mutex<FxHashMap<FontIdWithSize, Vec<LineWrapper>>>, wrapper_pool: Mutex<HashMap<FontIdWithSize, Vec<LineWrapper>>>,
font_runs_pool: Mutex<Vec<Vec<FontRun>>>, font_runs_pool: Mutex<Vec<Vec<FontRun>>>,
fallback_font_stack: SmallVec<[Font; 2]>, fallback_font_stack: SmallVec<[Font; 2]>,
} }
@ -447,7 +447,7 @@ impl WindowTextSystem {
Ok(lines) Ok(lines)
} }
pub(crate) fn finish_frame(&self, reused_views: &FxHashSet<EntityId>) { pub(crate) fn finish_frame(&self, reused_views: &HashSet<EntityId>) {
self.line_layout_cache.finish_frame(reused_views) self.line_layout_cache.finish_frame(reused_views)
} }

View File

@ -1,5 +1,5 @@
use crate::{px, EntityId, FontId, GlyphId, Pixels, PlatformTextSystem, Point, Size}; use crate::{px, EntityId, FontId, GlyphId, Pixels, PlatformTextSystem, Point, Size};
use collections::{FxHashMap, FxHashSet}; use collections::{HashMap, HashSet};
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{ use std::{
@ -277,10 +277,10 @@ impl WrappedLineLayout {
pub(crate) struct LineLayoutCache { pub(crate) struct LineLayoutCache {
view_stack: Mutex<Vec<EntityId>>, view_stack: Mutex<Vec<EntityId>>,
previous_frame: Mutex<FxHashMap<CacheKey, Arc<LineLayout>>>, previous_frame: Mutex<HashMap<CacheKey, Arc<LineLayout>>>,
current_frame: RwLock<FxHashMap<CacheKey, Arc<LineLayout>>>, current_frame: RwLock<HashMap<CacheKey, Arc<LineLayout>>>,
previous_frame_wrapped: Mutex<FxHashMap<CacheKey, Arc<WrappedLineLayout>>>, previous_frame_wrapped: Mutex<HashMap<CacheKey, Arc<WrappedLineLayout>>>,
current_frame_wrapped: RwLock<FxHashMap<CacheKey, Arc<WrappedLineLayout>>>, current_frame_wrapped: RwLock<HashMap<CacheKey, Arc<WrappedLineLayout>>>,
platform_text_system: Arc<dyn PlatformTextSystem>, platform_text_system: Arc<dyn PlatformTextSystem>,
} }
@ -296,7 +296,7 @@ impl LineLayoutCache {
} }
} }
pub fn finish_frame(&self, reused_views: &FxHashSet<EntityId>) { pub fn finish_frame(&self, reused_views: &HashSet<EntityId>) {
debug_assert_eq!(self.view_stack.lock().len(), 0); debug_assert_eq!(self.view_stack.lock().len(), 0);
let mut prev_frame = self.previous_frame.lock(); let mut prev_frame = self.previous_frame.lock();

View File

@ -10,7 +10,7 @@ use crate::{
WindowOptions, WindowTextSystem, WindowOptions, WindowTextSystem,
}; };
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use collections::FxHashSet; use collections::HashSet;
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use futures::{ use futures::{
channel::{mpsc, oneshot}, channel::{mpsc, oneshot},
@ -259,7 +259,7 @@ pub struct Window {
pub(crate) element_id_stack: GlobalElementId, pub(crate) element_id_stack: GlobalElementId,
pub(crate) rendered_frame: Frame, pub(crate) rendered_frame: Frame,
pub(crate) next_frame: Frame, pub(crate) next_frame: Frame,
pub(crate) dirty_views: FxHashSet<EntityId>, pub(crate) dirty_views: HashSet<EntityId>,
pub(crate) focus_handles: Arc<RwLock<SlotMap<FocusId, AtomicUsize>>>, pub(crate) focus_handles: Arc<RwLock<SlotMap<FocusId, AtomicUsize>>>,
focus_listeners: SubscriberSet<(), AnyWindowFocusListener>, focus_listeners: SubscriberSet<(), AnyWindowFocusListener>,
focus_lost_listeners: SubscriberSet<(), AnyObserver>, focus_lost_listeners: SubscriberSet<(), AnyObserver>,
@ -428,7 +428,7 @@ impl Window {
element_id_stack: GlobalElementId::default(), element_id_stack: GlobalElementId::default(),
rendered_frame: Frame::new(DispatchTree::new(cx.keymap.clone(), cx.actions.clone())), rendered_frame: Frame::new(DispatchTree::new(cx.keymap.clone(), cx.actions.clone())),
next_frame: Frame::new(DispatchTree::new(cx.keymap.clone(), cx.actions.clone())), next_frame: Frame::new(DispatchTree::new(cx.keymap.clone(), cx.actions.clone())),
dirty_views: FxHashSet::default(), dirty_views: HashSet::default(),
focus_handles: Arc::new(RwLock::new(SlotMap::with_key())), focus_handles: Arc::new(RwLock::new(SlotMap::with_key())),
focus_listeners: SubscriberSet::new(), focus_listeners: SubscriberSet::new(),
focus_lost_listeners: SubscriberSet::new(), focus_lost_listeners: SubscriberSet::new(),

View File

@ -21,7 +21,7 @@ use std::{
}; };
use anyhow::Result; use anyhow::Result;
use collections::{FxHashMap, FxHashSet}; use collections::{HashMap, HashSet};
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use media::core_video::CVImageBuffer; use media::core_video::CVImageBuffer;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -53,8 +53,8 @@ pub(crate) struct TooltipRequest {
pub(crate) struct Frame { pub(crate) struct Frame {
pub(crate) focus: Option<FocusId>, pub(crate) focus: Option<FocusId>,
pub(crate) window_active: bool, pub(crate) window_active: bool,
pub(crate) element_states: FxHashMap<GlobalElementId, ElementStateBox>, pub(crate) element_states: HashMap<GlobalElementId, ElementStateBox>,
pub(crate) mouse_listeners: FxHashMap<TypeId, Vec<(StackingOrder, EntityId, AnyMouseListener)>>, pub(crate) mouse_listeners: HashMap<TypeId, Vec<(StackingOrder, EntityId, AnyMouseListener)>>,
pub(crate) dispatch_tree: DispatchTree, pub(crate) dispatch_tree: DispatchTree,
pub(crate) scene: Scene, pub(crate) scene: Scene,
pub(crate) depth_map: Vec<(StackingOrder, EntityId, Bounds<Pixels>)>, pub(crate) depth_map: Vec<(StackingOrder, EntityId, Bounds<Pixels>)>,
@ -65,13 +65,13 @@ pub(crate) struct Frame {
pub(crate) element_offset_stack: Vec<Point<Pixels>>, pub(crate) element_offset_stack: Vec<Point<Pixels>>,
pub(crate) requested_input_handler: Option<RequestedInputHandler>, pub(crate) requested_input_handler: Option<RequestedInputHandler>,
pub(crate) tooltip_request: Option<TooltipRequest>, pub(crate) tooltip_request: Option<TooltipRequest>,
pub(crate) cursor_styles: FxHashMap<EntityId, CursorStyle>, pub(crate) cursor_styles: HashMap<EntityId, CursorStyle>,
pub(crate) requested_cursor_style: Option<CursorStyle>, pub(crate) requested_cursor_style: Option<CursorStyle>,
pub(crate) view_stack: Vec<EntityId>, pub(crate) view_stack: Vec<EntityId>,
pub(crate) reused_views: FxHashSet<EntityId>, pub(crate) reused_views: HashSet<EntityId>,
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
pub(crate) debug_bounds: collections::FxHashMap<String, Bounds<Pixels>>, pub(crate) debug_bounds: collections::HashMap<String, Bounds<Pixels>>,
} }
impl Frame { impl Frame {
@ -79,8 +79,8 @@ impl Frame {
Frame { Frame {
focus: None, focus: None,
window_active: false, window_active: false,
element_states: FxHashMap::default(), element_states: HashMap::default(),
mouse_listeners: FxHashMap::default(), mouse_listeners: HashMap::default(),
dispatch_tree, dispatch_tree,
scene: Scene::default(), scene: Scene::default(),
depth_map: Vec::new(), depth_map: Vec::new(),
@ -91,13 +91,13 @@ impl Frame {
element_offset_stack: Vec::new(), element_offset_stack: Vec::new(),
requested_input_handler: None, requested_input_handler: None,
tooltip_request: None, tooltip_request: None,
cursor_styles: FxHashMap::default(), cursor_styles: HashMap::default(),
requested_cursor_style: None, requested_cursor_style: None,
view_stack: Vec::new(), view_stack: Vec::new(),
reused_views: FxHashSet::default(), reused_views: HashSet::default(),
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
debug_bounds: FxHashMap::default(), debug_bounds: HashMap::default(),
} }
} }

View File

@ -8,6 +8,7 @@ use editor::{actions::Cancel, scroll::Autoscroll, Editor};
use file_associations::FileAssociations; use file_associations::FileAssociations;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use collections::{hash_map, HashMap};
use gpui::{ use gpui::{
actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext, actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
@ -22,14 +23,7 @@ use project::{
}; };
use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings}; use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{cmp::Ordering, ffi::OsStr, ops::Range, path::Path, sync::Arc};
cmp::Ordering,
collections::{hash_map, HashMap},
ffi::OsStr,
ops::Range,
path::Path,
sync::Arc,
};
use theme::ThemeSettings; use theme::ThemeSettings;
use ui::{prelude::*, v_flex, ContextMenu, Icon, KeyBinding, Label, ListItem}; use ui::{prelude::*, v_flex, ContextMenu, Icon, KeyBinding, Label, ListItem};
use unicase::UniCase; use unicase::UniCase;
@ -1699,15 +1693,13 @@ impl ClipboardEntry {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use collections::HashSet;
use gpui::{TestAppContext, View, VisualTestContext, WindowHandle}; use gpui::{TestAppContext, View, VisualTestContext, WindowHandle};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use project::{project_settings::ProjectSettings, FakeFs}; use project::{project_settings::ProjectSettings, FakeFs};
use serde_json::json; use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
use std::{ use std::path::{Path, PathBuf};
collections::HashSet,
path::{Path, PathBuf},
};
use workspace::AppState; use workspace::AppState;
#[gpui::test] #[gpui::test]
@ -3509,7 +3501,7 @@ mod tests {
cx: &mut VisualTestContext, cx: &mut VisualTestContext,
) -> Vec<String> { ) -> Vec<String> {
let mut result = Vec::new(); let mut result = Vec::new();
let mut project_entries = HashSet::new(); let mut project_entries = HashSet::default();
let mut has_editor = false; let mut has_editor = false;
panel.update(cx, |panel, cx| { panel.update(cx, |panel, cx| {

View File

@ -25,11 +25,11 @@ use project::{
}; };
use semantic_index::{SemanticIndex, SemanticIndexStatus}; use semantic_index::{SemanticIndex, SemanticIndexStatus};
use collections::HashSet;
use settings::Settings; use settings::Settings;
use smol::stream::StreamExt; use smol::stream::StreamExt;
use std::{ use std::{
any::{Any, TypeId}, any::{Any, TypeId},
collections::HashSet,
mem, mem,
ops::{Not, Range}, ops::{Not, Range},
path::PathBuf, path::PathBuf,
@ -955,7 +955,7 @@ impl ProjectSearchView {
semantic_state: None, semantic_state: None,
semantic_permissioned: None, semantic_permissioned: None,
search_options: options, search_options: options,
panels_with_errors: HashSet::new(), panels_with_errors: HashSet::default(),
active_match_index: None, active_match_index: None,
query_editor_was_focused: false, query_editor_was_focused: false,
included_files_editor, included_files_editor,

View File

@ -3,6 +3,7 @@ use ai::{
models::TruncationDirection, models::TruncationDirection,
}; };
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use collections::HashSet;
use language::{Grammar, Language}; use language::{Grammar, Language};
use rusqlite::{ use rusqlite::{
types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef}, types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef},
@ -12,7 +13,6 @@ use sha1::{Digest, Sha1};
use std::{ use std::{
borrow::Cow, borrow::Cow,
cmp::{self, Reverse}, cmp::{self, Reverse},
collections::HashSet,
ops::Range, ops::Range,
path::Path, path::Path,
sync::Arc, sync::Arc,
@ -267,7 +267,7 @@ impl CodeContextRetriever {
let mut spans = Vec::new(); let mut spans = Vec::new();
let mut collapsed_ranges_within = Vec::new(); let mut collapsed_ranges_within = Vec::new();
let mut parsed_name_ranges = HashSet::new(); let mut parsed_name_ranges = HashSet::default();
for (i, context_match) in matches.iter().enumerate() { for (i, context_match) in matches.iter().enumerate() {
// Items which are collapsible but not embeddable have no item range // Items which are collapsible but not embeddable have no item range
let item_range = if let Some(item_range) = context_match.item_range.clone() { let item_range = if let Some(item_range) = context_match.item_range.clone() {

View File

@ -7,6 +7,7 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
futures.workspace = true futures.workspace = true
indoc.workspace = true indoc.workspace = true
lazy_static.workspace = true lazy_static.workspace = true

View File

@ -1,8 +1,9 @@
use anyhow::Context; use anyhow::Context;
use collections::HashMap;
use futures::{channel::oneshot, Future, FutureExt}; use futures::{channel::oneshot, Future, FutureExt};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use std::{collections::HashMap, marker::PhantomData, ops::Deref, sync::Arc, thread}; use std::{marker::PhantomData, ops::Deref, sync::Arc, thread};
use thread_local::ThreadLocal; use thread_local::ThreadLocal;
use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender}; use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender};

View File

@ -13,6 +13,7 @@ doctest = false
[dependencies] [dependencies]
alacritty_terminal = "0.22.0" alacritty_terminal = "0.22.0"
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
db.workspace = true db.workspace = true
dirs = "4.0.0" dirs = "4.0.0"
futures.workspace = true futures.workspace = true

View File

@ -30,6 +30,7 @@ use mappings::mouse::{
scroll_report, scroll_report,
}; };
use collections::{HashMap, VecDeque};
use procinfo::LocalProcessInfo; use procinfo::LocalProcessInfo;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use settings::Settings; use settings::Settings;
@ -39,7 +40,6 @@ use util::truncate_and_trailoff;
use std::{ use std::{
cmp::{self, min}, cmp::{self, min},
collections::{HashMap, VecDeque},
fmt::Display, fmt::Display,
ops::{Deref, Index, RangeInclusive}, ops::{Deref, Index, RangeInclusive},
os::unix::prelude::AsRawFd, os::unix::prelude::AsRawFd,

View File

@ -1,3 +1,4 @@
use collections::HashMap;
use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels}; use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels};
use schemars::{ use schemars::{
gen::SchemaGenerator, gen::SchemaGenerator,
@ -7,7 +8,7 @@ use schemars::{
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use settings::SettingsJsonSchemaParams; use settings::SettingsJsonSchemaParams;
use std::{collections::HashMap, path::PathBuf}; use std::path::PathBuf;
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]

View File

@ -8,11 +8,7 @@ license = "GPL-3.0-or-later"
[features] [features]
default = [] default = []
stories = ["dep:itertools", "dep:story"] stories = ["dep:itertools", "dep:story"]
test-support = [ test-support = ["gpui/test-support", "fs/test-support", "settings/test-support"]
"gpui/test-support",
"fs/test-support",
"settings/test-support"
]
[lib] [lib]
path = "src/theme.rs" path = "src/theme.rs"
@ -20,6 +16,7 @@ doctest = false
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
collections.workspace = true
color.workspace = true color.workspace = true
derive_more.workspace = true derive_more.workspace = true
fs.workspace = true fs.workspace = true

View File

@ -1,8 +1,8 @@
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use collections::HashMap;
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use fs::Fs; use fs::Fs;
use futures::StreamExt; use futures::StreamExt;
@ -64,7 +64,7 @@ impl ThemeRegistry {
pub fn new(assets: Box<dyn AssetSource>) -> Self { pub fn new(assets: Box<dyn AssetSource>) -> Self {
let registry = Self { let registry = Self {
state: RwLock::new(ThemeRegistryState { state: RwLock::new(ThemeRegistryState {
themes: HashMap::new(), themes: HashMap::default(),
}), }),
assets, assets,
}; };

View File

@ -15,6 +15,7 @@ test-support = ["tempfile", "git2"]
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
backtrace = "0.3" backtrace = "0.3"
collections.workspace = true
dirs = "3.0" dirs = "3.0"
futures.workspace = true futures.workspace = true
git2 = { workspace = true, optional = true } git2 = { workspace = true, optional = true }

View File

@ -1,4 +1,5 @@
use std::{cmp::Ordering, collections::HashMap, ops::Range}; use collections::HashMap;
use std::{cmp::Ordering, ops::Range};
/// Construct a string and a list of offsets within that string using a single /// Construct a string and a list of offsets within that string using a single
/// string containing embedded position markers. /// string containing embedded position markers.

View File

@ -1,6 +1,7 @@
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use cli::{ipc, IpcHandshake}; use cli::{ipc, IpcHandshake};
use cli::{ipc::IpcSender, CliRequest, CliResponse}; use cli::{ipc::IpcSender, CliRequest, CliResponse};
use collections::HashMap;
use editor::scroll::Autoscroll; use editor::scroll::Autoscroll;
use editor::Editor; use editor::Editor;
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
@ -10,7 +11,6 @@ use gpui::{AppContext, AsyncAppContext, Global};
use itertools::Itertools; use itertools::Itertools;
use language::{Bias, Point}; use language::{Bias, Point};
use release_channel::parse_zed_link; use release_channel::parse_zed_link;
use std::collections::HashMap;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::OsStrExt;
use std::path::Path; use std::path::Path;
@ -176,7 +176,7 @@ pub async fn handle_cli_connection(
if let Some(request) = requests.next().await { if let Some(request) = requests.next().await {
match request { match request {
CliRequest::Open { paths, wait } => { CliRequest::Open { paths, wait } => {
let mut caret_positions = HashMap::new(); let mut caret_positions = HashMap::default();
let paths = if paths.is_empty() { let paths = if paths.is_empty() {
workspace::last_opened_workspace_paths() workspace::last_opened_workspace_paths()

View File

@ -733,6 +733,7 @@ fn open_settings_file(
mod tests { mod tests {
use super::*; use super::*;
use assets::Assets; use assets::Assets;
use collections::HashSet;
use editor::{scroll::Autoscroll, DisplayPoint, Editor}; use editor::{scroll::Autoscroll, DisplayPoint, Editor};
use gpui::{ use gpui::{
actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext, actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext,
@ -742,10 +743,7 @@ mod tests {
use project::{project_settings::ProjectSettings, Project, ProjectPath}; use project::{project_settings::ProjectSettings, Project, ProjectPath};
use serde_json::json; use serde_json::json;
use settings::{handle_settings_file_changes, watch_config_file, SettingsStore}; use settings::{handle_settings_file_changes, watch_config_file, SettingsStore};
use std::{ use std::path::{Path, PathBuf};
collections::HashSet,
path::{Path, PathBuf},
};
use theme::{ThemeRegistry, ThemeSettings}; use theme::{ThemeRegistry, ThemeSettings};
use workspace::{ use workspace::{
item::{Item, ItemHandle}, item::{Item, ItemHandle},