From 2b3f26fc29952296fdf79fa43d5beb35ddacbf40 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 17 Jan 2024 17:07:58 -0600 Subject: [PATCH] perf(fmt): Avoid UTF-8 validation --- src/fmt/writer/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fmt/writer/mod.rs b/src/fmt/writer/mod.rs index 52265d4..fa7ce1f 100644 --- a/src/fmt/writer/mod.rs +++ b/src/fmt/writer/mod.rs @@ -68,18 +68,18 @@ impl WritableTarget { match self { WritableTarget::WriteStdout => { let mut stream = std::io::stdout().lock(); - write!(stream, "{}", String::from_utf8_lossy(buf))?; + stream.write_all(buf)?; } WritableTarget::PrintStdout => print!("{}", String::from_utf8_lossy(buf)), WritableTarget::WriteStderr => { let mut stream = std::io::stderr().lock(); - write!(stream, "{}", String::from_utf8_lossy(buf))?; + stream.write_all(buf)?; } WritableTarget::PrintStderr => eprint!("{}", String::from_utf8_lossy(buf)), // Safety: If the target type is `Pipe`, `target_pipe` will always be non-empty. WritableTarget::Pipe(pipe) => { let mut stream = pipe.lock().unwrap(); - write!(stream, "{}", String::from_utf8_lossy(buf))?; + stream.write_all(buf)?; } }