Skip to content

Commit

Permalink
perf(fmt): Avoid UTF-8 validation
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 17, 2024
1 parent 7428386 commit 2b3f26f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/fmt/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
}

Expand Down

0 comments on commit 2b3f26f

Please # to comment.