From 87aab4cacbd74b4cf163e7ec5918750eb7b2708e Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Mon, 18 Mar 2024 19:55:21 +0800 Subject: [PATCH] chore: avoid unnecessary cloning --- src/promql/src/extension_plan/series_divide.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/promql/src/extension_plan/series_divide.rs b/src/promql/src/extension_plan/series_divide.rs index 772ee079eb77..73fffbdeeb10 100644 --- a/src/promql/src/extension_plan/series_divide.rs +++ b/src/promql/src/extension_plan/series_divide.rs @@ -255,20 +255,18 @@ impl Stream for SeriesDivideStream { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { loop { - if let Some(batch) = self.buffer.clone() { + if let Some(batch) = self.buffer.take() { let same_length = self.find_first_diff_row(&batch) + 1; if same_length >= batch.num_rows() { let next_batch = match ready!(self.as_mut().fetch_next_batch(cx)) { - Some(Ok(batch)) => batch, + Some(Ok(next_batch)) => next_batch, None => { - self.buffer = None; self.num_series += 1; return Poll::Ready(Some(Ok(batch))); } error => return Poll::Ready(error), }; - let new_batch = - compute::concat_batches(&batch.schema(), &[batch.clone(), next_batch])?; + let new_batch = compute::concat_batches(&batch.schema(), &[batch, next_batch])?; self.buffer = Some(new_batch); continue; } else {