diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-04-28 13:41:11 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-04-28 13:41:11 +0200 |
| commit | b6393783d07405d0a13e03f6e752428974703754 (patch) | |
| tree | 0420e3956ae20245a977d81740b0bcc5b68dc77e /crates/nasm | |
| parent | f6b520c114ec4130513a26ab074d3141854afb59 (diff) | |
| download | tools.nes-b6393783d07405d0a13e03f6e752428974703754.tar.gz tools.nes-b6393783d07405d0a13e03f6e752428974703754.zip | |
nasm: use buffered writing for full ROMs as well
This was already implemented for the --split-segments option. Not let's
bring this when building full ROM files, as writing things byte by byte
is slow.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'crates/nasm')
| -rw-r--r-- | crates/nasm/src/main.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index 2668556..12ac887 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -308,14 +308,14 @@ fn main() { }; // Select the output stream. - let (mut output, output_name): (Box<dyn Write>, &str) = if args.stdout { - (Box::new(io::stdout()), "<stdout>") + let (mut output, output_name): (BufWriter<Box<dyn Write>>, &str) = if args.stdout { + (BufWriter::new(Box::new(io::stdout())), "<stdout>") } else if args.split { - (Box::new(io::stdout()), "<segments>") + (BufWriter::new(Box::new(io::stdout())), "<segments>") } else { let name = args.out.unwrap_or(String::from("out.nes")); match File::create(&name) { - Ok(f) => (Box::new(f), args.file.as_str()), + Ok(f) => (BufWriter::new(Box::new(f)), args.file.as_str()), Err(_) => { die(format!("could not create file '{name}'")); return; @@ -419,6 +419,10 @@ fn main() { eprintln!("error: could not write result in '{output_name}': {e}"); std::process::exit(1); } + if let Err(e) = output.flush() { + eprintln!("error: could not write to '{output_name}': {e}"); + std::process::exit(1); + } } } |
