mirror of
https://github.com/openharmony/third_party_rust_termcolor.git
synced 2026-07-01 21:34:00 -04:00
impl: add explicit Ansi::write_all definition
This gives a large speedup when doing small writes into an `Ansi<BufWriter<...>>`. Closes #56
This commit is contained in:
committed by
Andrew Gallant
parent
3f24303f2e
commit
461ab13ac9
+11
@@ -1340,6 +1340,17 @@ impl<W: io::Write> io::Write for Ansi<W> {
|
||||
self.0.write(buf)
|
||||
}
|
||||
|
||||
// Adding this method here is not required because it has a default impl,
|
||||
// but it seems to provide a perf improvement in some cases when using
|
||||
// a `BufWriter` with lots of writes.
|
||||
//
|
||||
// See https://github.com/BurntSushi/termcolor/pull/56 for more details
|
||||
// and a minimized example.
|
||||
#[inline]
|
||||
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||
self.0.write_all(buf)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
self.0.flush()
|
||||
|
||||
Reference in New Issue
Block a user