lock stdout for faster writes

This commit is contained in:
Marcello 2024-03-09 11:28:28 +01:00
parent c42a606930
commit cfa0b5c8a2
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk

View file

@ -41,13 +41,13 @@ fn main() -> Result<()> {
.join("\n");
let mut writer: Box<dyn Write> = match args.output {
None => Box::new(std::io::stdout().lock()),
Some(ref filename) => {
let file = File::create(filename)
.with_context(|| format!("Could not open file `{filename}`"))?;
Box::new(BufWriter::new(file))
}
None => Box::new(std::io::stdout()),
};
let output = args.output.unwrap_or("STDOUT".to_string());
@ -105,7 +105,6 @@ impl JsonParser {
struct EnvVar(String, Value);
impl Display for EnvVar {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.1 {