Remove unnecessary clone (#6729)

This commit is contained in:
Doru 2022-10-14 19:13:24 -03:00 committed by GitHub
parent 7532991544
commit da6f548dfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,7 +155,7 @@ impl Command for Window {
group_size: group_size.item, group_size: group_size.item,
input: Box::new(input.into_iter()), input: Box::new(input.into_iter()),
span: call.head, span: call.head,
previous: vec![], previous: None,
stride, stride,
}; };
@ -169,7 +169,7 @@ struct EachWindowIterator {
group_size: usize, group_size: usize,
input: Box<dyn Iterator<Item = Value> + Send>, input: Box<dyn Iterator<Item = Value> + Send>,
span: Span, span: Span,
previous: Vec<Value>, previous: Option<Vec<Value>>,
stride: usize, stride: usize,
} }
@ -177,7 +177,7 @@ impl Iterator for EachWindowIterator {
type Item = Value; type Item = Value;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let mut group = self.previous.clone(); let mut group = self.previous.take().unwrap_or_default();
let mut current_count = 0; let mut current_count = 0;
if group.is_empty() { if group.is_empty() {
@ -222,10 +222,11 @@ impl Iterator for EachWindowIterator {
return None; return None;
} }
self.previous = group.clone(); let return_group = group.clone();
self.previous = Some(group);
Some(Value::List { Some(Value::List {
vals: group, vals: return_group,
span: self.span, span: self.span,
}) })
} }