Skip to content

Commit

Permalink
BufWriter: assert the buffer is empty when bypassing
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Ryhl <alice@ryhl.io>
  • Loading branch information
mzabaluev and Darksonn committed Jun 29, 2021
1 parent 2dff0ad commit 598560b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tokio/src/io/util/buf_writer.rs
Expand Up @@ -174,6 +174,7 @@ impl<W: AsyncWrite> AsyncWrite for BufWriter<W> {
if first_len >= me.buf.capacity() {
// The slice is at least as large as the buffering capacity,
// so it's better to write it directly, bypassing the buffer.
debug_assert!(me.buf.is_empty());
return me.inner.poll_write(cx, &bufs[0]);
} else {
me.buf.extend_from_slice(&bufs[0]);
Expand Down

0 comments on commit 598560b

Please sign in to comment.