Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io: use BufMut::put_bytes in Repeat read impl #7055

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
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());
paolobarbolini marked this conversation as resolved.
Show resolved Hide resolved
Poll::Ready(Ok(()))
}
}
Expand Down
Loading