diff options
author | Blaž Hrastnik | 2021-08-31 09:29:24 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-08-31 09:29:24 +0000 |
commit | a3bd80a6fa4f07b0fa581eae416376763ba94345 (patch) | |
tree | 3681dedb9aed053396ed20d9937a868dbbdba9fc /helix-term/src/ui | |
parent | 9b96bb5ac802189f567b101f7c8da4b370a2fdd1 (diff) |
ui: prompt: Avoid allocating a prompt name if it's a static string
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/mod.rs | 2 | ||||
-rw-r--r-- | helix-term/src/ui/picker.rs | 2 | ||||
-rw-r--r-- | helix-term/src/ui/prompt.rs | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index f3f8670e..0a1e24b5 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -27,7 +27,7 @@ use std::path::PathBuf; pub fn regex_prompt( cx: &mut crate::commands::Context, - prompt: String, + prompt: std::borrow::Cow<'static, str>, fun: impl Fn(&mut View, &mut Document, &mut Registers, Regex) + 'static, ) -> Prompt { let (view, doc) = current!(cx.editor); diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index ef2c434c..06e424ea 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -202,7 +202,7 @@ impl<T> Picker<T> { callback_fn: impl Fn(&mut Editor, &T, Action) + 'static, ) -> Self { let prompt = Prompt::new( - "".to_string(), + "".into(), None, |_pattern: &str| Vec::new(), |_editor: &mut Context, _pattern: &str, _event: PromptEvent| { diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 7197adea..1d512ad2 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -15,7 +15,7 @@ use helix_view::{ pub type Completion = (RangeFrom<usize>, Cow<'static, str>); pub struct Prompt { - prompt: String, + prompt: Cow<'static, str>, pub line: String, cursor: usize, completion: Vec<Completion>, @@ -55,7 +55,7 @@ pub enum Movement { impl Prompt { pub fn new( - prompt: String, + prompt: Cow<'static, str>, history_register: Option<char>, mut completion_fn: impl FnMut(&str) -> Vec<Completion> + 'static, callback_fn: impl FnMut(&mut Context, &str, PromptEvent) + 'static, |