diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 658bf9f99b9..4441864be66 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -91,7 +91,7 @@ tokio-macros = { version = "~2.4.0", path = "../tokio-macros", optional = true } pin-project-lite = "0.2.11" # Everything else is optional... -bytes = { version = "1.0.0", optional = true } +bytes = { version = "1.1.0", optional = true } mio = { version = "1.0.1", optional = true, default-features = false } parking_lot = { version = "0.12.0", optional = true } diff --git a/tokio/src/io/util/repeat.rs b/tokio/src/io/util/repeat.rs index ecdbc7d062c..33a8fd9862b 100644 --- a/tokio/src/io/util/repeat.rs +++ b/tokio/src/io/util/repeat.rs @@ -1,3 +1,5 @@ +use bytes::BufMut; + use crate::io::util::poll_proceed_and_make_progress; use crate::io::{AsyncRead, ReadBuf}; @@ -56,10 +58,7 @@ impl AsyncRead for Repeat { ) -> Poll> { 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(())) } }