diff --git a/src/mito2/src/memtable/merge_tree/data.rs b/src/mito2/src/memtable/merge_tree/data.rs index eb6b064dabc5..3acdf76e9166 100644 --- a/src/mito2/src/memtable/merge_tree/data.rs +++ b/src/mito2/src/memtable/merge_tree/data.rs @@ -209,17 +209,15 @@ impl Iterator for Iter { type Item = Result; fn next(&mut self) -> Option { - while let Some(mut top) = self.heap.pop() { - let top_batch = top.source.current_batch(); - if let Err(e) = top.source.next() { - return Some(Err(e)); - } - if top.source.is_valid() { - self.heap.push(top); - } - return Some(Ok(top_batch)); + let mut top = self.heap.pop()?; + let top_batch = top.source.current_batch(); + if let Err(e) = top.source.next() { + return Some(Err(e)); + } + if top.source.is_valid() { + self.heap.push(top); } - None + Some(Ok(top_batch)) } }