Skip to content

Commit

Permalink
io: use Buf::put_bytes in Repeat read impl
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini committed Dec 29, 2024
1 parent 970d880 commit 2180217
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tokio/src/io/util/repeat.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use bytes::BufMut;

use crate::io::util::poll_proceed_and_make_progress;
use crate::io::{AsyncRead, ReadBuf};

Expand Down Expand Up @@ -56,10 +58,7 @@ impl AsyncRead for Repeat {
) -> Poll<io::Result<()>> {
ready!(crate::trace::trace_leaf(cx));
ready!(poll_proceed_and_make_progress(cx));
// TODO: could be faster, but should we unsafe it?
while buf.remaining() != 0 {
buf.put_slice(&[self.byte]);
}
buf.put_bytes(self.byte, buf.remaining());
Poll::Ready(Ok(()))
}
}
Expand Down

0 comments on commit 2180217

Please sign in to comment.