Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Don't allocate interactive bounds
Nathan Sobo0d30b698a493
diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rsindex cc82ff3cb09..fa8ef50bbb7 100644--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@ -748,10 +748,10 @@ impl Interactivity {cx.with_z_index(style.z_index.unwrap_or(0), |cx| cx.add_opaque_layer(bounds))}- let interactive_bounds = Rc::new(InteractiveBounds {+ let interactive_bounds = InteractiveBounds {bounds: bounds.intersect(&cx.content_mask().bounds),stacking_order: cx.stacking_order().clone(),- });+ };if let Some(mouse_cursor) = style.mouse_cursor {let mouse_position = &cx.mouse_position();@@ -784,28 +784,28 @@ impl Interactivity {for listener in self.mouse_down_listeners {let interactive_bounds = interactive_bounds.clone();cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {- listener(event, &*interactive_bounds, phase, cx);+ listener(event, &interactive_bounds, phase, cx);})}for listener in self.mouse_up_listeners {let interactive_bounds = interactive_bounds.clone();cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {- listener(event, &*interactive_bounds, phase, cx);+ listener(event, &interactive_bounds, phase, cx);})}for listener in self.mouse_move_listeners {let interactive_bounds = interactive_bounds.clone();cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {- listener(event, &*interactive_bounds, phase, cx);+ listener(event, &interactive_bounds, phase, cx);})}for listener in self.scroll_wheel_listeners {let interactive_bounds = interactive_bounds.clone();cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {- listener(event, &*interactive_bounds, phase, cx);+ listener(event, &interactive_bounds, phase, cx);})}diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rsindex 31e9afc6953..d43263f8157 100644--- a/crates/gpui2/src/window.rs+++ b/crates/gpui2/src/window.rs@@ -46,29 +46,17 @@ const ACTIVE_DRAG_Z_INDEX: u8 = 1;pub struct StackingOrder {#[deref]#[deref_mut]- z_indices: Arc<SmallVec<[u8; 8]>>,+ z_indices: SmallVec<[u8; 32]>,}impl Default for StackingOrder {fn default() -> Self {StackingOrder {- z_indices: Arc::new(SmallVec::new()),+ z_indices: SmallVec::new(),}}}-impl StackingOrder {- /// Pushes a new z-index onto the stacking order.- pub fn push(&mut self, z_index: u8) {- Arc::make_mut(&mut self.z_indices).push(z_index);- }-- /// Pops the last z-index off the stacking order.- pub fn pop(&mut self) {- Arc::make_mut(&mut self.z_indices).pop();- }-}-/// Represents the two different phases when dispatching events.#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]pub enum DispatchPhase {