From ce02824f3c4c6a750a30651b478ff255d68ff0de Mon Sep 17 00:00:00 2001 From: Alexandre Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:11:02 +0200 Subject: [PATCH] perf(stdin): avoid unnecessary allocations when streaming from stdin (#475) --- television/channels/stdin.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/television/channels/stdin.rs b/television/channels/stdin.rs index 7b32b25..cecde34 100644 --- a/television/channels/stdin.rs +++ b/television/channels/stdin.rs @@ -77,10 +77,10 @@ fn stream_from_stdin(injector: &Injector) { loop { match stdin.read_line(&mut buffer) { Ok(c) if c > 0 => { - let buf = buffer.trim(); - if !buf.is_empty() { - injector.push(buf.to_string(), |e, cols| { - cols[0] = e.to_string().into(); + let trimmed = buffer.trim(); + if !trimmed.is_empty() { + injector.push(trimmed.to_owned(), |e, cols| { + cols[0] = e.clone().into(); }); } buffer.clear();