From da6f548dfdf101ebf0aaa1c27a5000df6d966c6a Mon Sep 17 00:00:00 2001 From: Doru Date: Fri, 14 Oct 2022 19:13:24 -0300 Subject: [PATCH] Remove unnecessary clone (#6729) --- crates/nu-command/src/filters/window.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/filters/window.rs b/crates/nu-command/src/filters/window.rs index fa7c02e90..58073c62a 100644 --- a/crates/nu-command/src/filters/window.rs +++ b/crates/nu-command/src/filters/window.rs @@ -155,7 +155,7 @@ impl Command for Window { group_size: group_size.item, input: Box::new(input.into_iter()), span: call.head, - previous: vec![], + previous: None, stride, }; @@ -169,7 +169,7 @@ struct EachWindowIterator { group_size: usize, input: Box + Send>, span: Span, - previous: Vec, + previous: Option>, stride: usize, } @@ -177,7 +177,7 @@ impl Iterator for EachWindowIterator { type Item = Value; fn next(&mut self) -> Option { - let mut group = self.previous.clone(); + let mut group = self.previous.take().unwrap_or_default(); let mut current_count = 0; if group.is_empty() { @@ -222,10 +222,11 @@ impl Iterator for EachWindowIterator { return None; } - self.previous = group.clone(); + let return_group = group.clone(); + self.previous = Some(group); Some(Value::List { - vals: group, + vals: return_group, span: self.span, }) }