From aa4c438f830e64f9427b28e805fae06f86f6f330 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 17 Feb 2025 12:43:28 -0700 Subject: [PATCH] Use `Vec` for `KeyContext` instead of `SmallVec` (#24916) In Zed the key context almost always has more than 1 entry, so use of `SmallVec` is just adding overhead. In Zed while using the editor this typically has more than 8 entries. Since `ContextEntry` is 48 bytes, if this were made to be a `SmallVec<[ContextEntry; 10]>` then it would use 480 bytes on the stack, which to me seems like a lot to be copying. So, instead opting to just use `Vec` Release Notes: - N/A --- crates/gpui/src/keymap/context.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/gpui/src/keymap/context.rs b/crates/gpui/src/keymap/context.rs index 3dc8292a5f..2968f6909e 100644 --- a/crates/gpui/src/keymap/context.rs +++ b/crates/gpui/src/keymap/context.rs @@ -1,6 +1,5 @@ use crate::SharedString; use anyhow::{anyhow, Result}; -use smallvec::SmallVec; use std::fmt; /// A datastructure for resolving whether an action should be dispatched @@ -8,7 +7,7 @@ use std::fmt; /// and/or key value pairs representing the current context for the /// keymap. #[derive(Clone, Default, Eq, PartialEq, Hash)] -pub struct KeyContext(SmallVec<[ContextEntry; 1]>); +pub struct KeyContext(Vec); #[derive(Clone, Debug, Eq, PartialEq, Hash)] /// An entry in a KeyContext