mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
io: remove zeroing for AsyncRead implementors (#2525)
This commit is contained in:
parent
4f4f4807c3
commit
1e54a35325
@ -537,6 +537,11 @@ impl File {
|
||||
}
|
||||
|
||||
impl AsyncRead for File {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
// https://github.com/rust-lang/rust/blob/09c817eeb29e764cfc12d0a8d94841e3ffe34023/src/libstd/fs.rs#L668
|
||||
false
|
||||
}
|
||||
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
@ -76,7 +76,7 @@ pub trait AsyncRead {
|
||||
/// [`poll_read_buf`]: #method.poll_read_buf
|
||||
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit<u8>]) -> bool {
|
||||
for x in buf {
|
||||
*x.as_mut_ptr() = 0;
|
||||
*x = MaybeUninit::new(0);
|
||||
}
|
||||
|
||||
true
|
||||
|
@ -183,6 +183,7 @@ mod async_buf_read;
|
||||
pub use self::async_buf_read::AsyncBufRead;
|
||||
|
||||
mod async_read;
|
||||
|
||||
pub use self::async_read::AsyncRead;
|
||||
|
||||
mod async_seek;
|
||||
|
@ -63,6 +63,11 @@ impl std::os::windows::io::AsRawHandle for Stdin {
|
||||
}
|
||||
|
||||
impl AsyncRead for Stdin {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
// https://github.com/rust-lang/rust/blob/09c817eeb29e764cfc12d0a8d94841e3ffe34023/src/libstd/io/stdio.rs#L97
|
||||
false
|
||||
}
|
||||
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
@ -84,6 +84,15 @@ where
|
||||
T: AsyncRead,
|
||||
U: AsyncRead,
|
||||
{
|
||||
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
if self.first.prepare_uninitialized_buffer(buf) {
|
||||
return true;
|
||||
}
|
||||
if self.second.prepare_uninitialized_buffer(buf) {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
fn poll_read(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
@ -47,6 +47,9 @@ cfg_io_util! {
|
||||
}
|
||||
|
||||
impl AsyncRead for Empty {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
false
|
||||
}
|
||||
#[inline]
|
||||
fn poll_read(
|
||||
self: Pin<&mut Self>,
|
||||
|
@ -47,6 +47,9 @@ cfg_io_util! {
|
||||
}
|
||||
|
||||
impl AsyncRead for Repeat {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
false
|
||||
}
|
||||
#[inline]
|
||||
fn poll_read(
|
||||
self: Pin<&mut Self>,
|
||||
|
@ -879,6 +879,11 @@ impl AsyncWrite for ChildStdin {
|
||||
}
|
||||
|
||||
impl AsyncRead for ChildStdout {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
// https://github.com/rust-lang/rust/blob/09c817eeb29e764cfc12d0a8d94841e3ffe34023/src/libstd/process.rs#L314
|
||||
false
|
||||
}
|
||||
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
@ -889,6 +894,11 @@ impl AsyncRead for ChildStdout {
|
||||
}
|
||||
|
||||
impl AsyncRead for ChildStderr {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
|
||||
// https://github.com/rust-lang/rust/blob/09c817eeb29e764cfc12d0a8d94841e3ffe34023/src/libstd/process.rs#L375
|
||||
false
|
||||
}
|
||||
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user