Rollup merge of #114194 - thomcc:flushinline, r=cuviper

Inline trivial (noop) flush calls

At work I noticed that `writer.flush()?` didn't get optimized away in cases where the flush is obviously a no-op, which I had expected (well, desired).

I went through and added `#[inline]` to a bunch of cases that were obviously noops, or delegated to ones that were obviously noops. I omitted platforms I don't have access to (some tier3). I didn't do this very scientifically, in cases where it was non-obvious I left `#[inline]` off.
This commit is contained in:
Michael Goulet 2023-08-10 21:17:36 -07:00 committed by GitHub
commit 0c241e6bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 0 deletions

View File

@ -791,6 +791,7 @@ impl Write for &File {
self.inner.is_write_vectored() self.inner.is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
self.inner.flush() self.inner.flush()
} }
@ -836,6 +837,7 @@ impl Write for File {
fn is_write_vectored(&self) -> bool { fn is_write_vectored(&self) -> bool {
(&&*self).is_write_vectored() (&&*self).is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
(&*self).flush() (&*self).flush()
} }
@ -881,6 +883,7 @@ impl Write for Arc<File> {
fn is_write_vectored(&self) -> bool { fn is_write_vectored(&self) -> bool {
(&**self).is_write_vectored() (&**self).is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
(&**self).flush() (&**self).flush()
} }

View File

@ -310,6 +310,7 @@ impl<'a> Write for BorrowedCursor<'a> {
Ok(buf.len()) Ok(buf.len())
} }
#[inline]
fn flush(&mut self) -> Result<()> { fn flush(&mut self) -> Result<()> {
Ok(()) Ok(())
} }

View File

@ -647,6 +647,7 @@ impl Write for TcpStream {
self.0.is_write_vectored() self.0.is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }
@ -685,6 +686,7 @@ impl Write for &TcpStream {
self.0.is_write_vectored() self.0.is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }

View File

@ -712,6 +712,7 @@ impl<'a> io::Write for &'a UnixStream {
self.0.is_write_vectored() self.0.is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }

View File

@ -280,6 +280,7 @@ impl Write for ChildStdin {
io::Write::is_write_vectored(&&*self) io::Write::is_write_vectored(&&*self)
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
(&*self).flush() (&*self).flush()
} }
@ -299,6 +300,7 @@ impl Write for &ChildStdin {
self.inner.is_write_vectored() self.inner.is_write_vectored()
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }

View File

@ -335,6 +335,7 @@ impl File {
false false
} }
#[inline]
pub fn flush(&self) -> io::Result<()> { pub fn flush(&self) -> io::Result<()> {
Ok(()) Ok(())
} }

View File

@ -1204,6 +1204,7 @@ impl File {
self.0.write_vectored_at(bufs, offset) self.0.write_vectored_at(bufs, offset)
} }
#[inline]
pub fn flush(&self) -> io::Result<()> { pub fn flush(&self) -> io::Result<()> {
Ok(()) Ok(())
} }

View File

@ -54,6 +54,7 @@ impl io::Write for Stdout {
true true
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }
@ -81,6 +82,7 @@ impl io::Write for Stderr {
true true
} }
#[inline]
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {
Ok(()) Ok(())
} }