Skip to content

Commit 3b83a48

Browse files
committed
chore: added short-circuit
1 parent 325afc6 commit 3b83a48

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/cbq/write.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ impl<W: io::Write> ColumnarBlockWriter<W> {
140140
/// `other` keeps building its incomplete block across calls; only its
141141
/// completed-block buffer and headers are drained.
142142
pub fn ingest_completed(&mut self, other: &mut ColumnarBlockWriter<Vec<u8>>) -> Result<()> {
143+
if other.headers.is_empty() {
144+
return Ok(()); // short-circuit
145+
}
146+
143147
// Write all completed blocks from the other
144148
self.inner.write_all(other.inner_data())?;
145149

@@ -160,6 +164,10 @@ impl<W: io::Write> ColumnarBlockWriter<W> {
160164
///
161165
/// [`ingest_completed`](Self::ingest_completed) should always be called first.
162166
fn ingest_incompleted(&mut self, other: &mut ColumnarBlockWriter<Vec<u8>>) -> Result<()> {
167+
if other.block.num_records == 0 {
168+
return Ok(()); // short-circuit
169+
}
170+
163171
// Attempt to ingest the incomplete block from the other
164172
if !self.block.can_ingest(&other.block) {
165173
// Make space by flushing the current block

0 commit comments

Comments
 (0)