From b793a8756bbda9845e80a228740ec587b5b2908c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 27 Jun 2026 01:42:31 +0300 Subject: [PATCH] beer-protocols/key: shrimplify prefix_alt Co-authored-by: faukah Signed-off-by: NotAShelf Change-Id: Icc8c25203c31fc0c2ecaa66ab5d433b66a6a6964 --- crates/beer-protocols/src/key.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/beer-protocols/src/key.rs b/crates/beer-protocols/src/key.rs index 0dc0348..edc0780 100644 --- a/crates/beer-protocols/src/key.rs +++ b/crates/beer-protocols/src/key.rs @@ -9,8 +9,8 @@ use smithay_client_toolkit::seat::keyboard::{KeyEvent, Keysym, Modifiers}; /// (DECCKM). pub fn encode(event: &KeyEvent, mods: Modifiers, app_cursor: bool) -> Option> { let seq = match event.keysym { - Keysym::Return | Keysym::KP_Enter => prefix_alt(b"\r".to_vec(), mods), - Keysym::BackSpace => prefix_alt(b"\x7f".to_vec(), mods), + Keysym::Return | Keysym::KP_Enter => prefix_alt(b"\r", mods), + Keysym::BackSpace => prefix_alt(b"\x7f", mods), Keysym::Tab if mods.shift => b"\x1b[Z".to_vec(), Keysym::Tab => b"\t".to_vec(), Keysym::Escape => b"\x1b".to_vec(), @@ -48,7 +48,7 @@ pub fn encode(event: &KeyEvent, mods: Modifiers, app_cursor: bool) -> Option Stri cp.to_string() } -fn prefix_alt(bytes: Vec, mods: Modifiers) -> Vec { +fn prefix_alt(bytes: &[u8], mods: Modifiers) -> Vec { if mods.alt { let mut out = Vec::with_capacity(bytes.len() + 1); out.push(0x1b); - out.extend_from_slice(&bytes); + out.extend_from_slice(bytes); out } else { - bytes + bytes.to_vec() } }