aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/assembler.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-17 07:42:20 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-17 07:42:20 +0200
commit6631bc777affdbb371b64495c4aeb34b031cf7a1 (patch)
treee3429ae656ad1472c0a2b5dcf38a1c95b293785a /lib/xixanta/src/assembler.rs
parent3d772470b09c4a8b78f526c3fd566c0aae1ab94f (diff)
downloadtools.nes-6631bc777affdbb371b64495c4aeb34b031cf7a1.tar.gz
tools.nes-6631bc777affdbb371b64495c4aeb34b031cf7a1.zip
Use a buffered reader for incbin
Iterating via `bytes()` on a file is inefficient as the default implementation calls `read` on each byte, which can be costly on bytes which are not in memory like files. This is extra important for statements like `incbin` as included files can be rather big. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/assembler.rs')
-rw-r--r--lib/xixanta/src/assembler.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index 5b01db8..6fc0cc1 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -8,7 +8,7 @@ use crate::SourceInfo;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fs::File;
-use std::io::Read;
+use std::io::{BufReader, Read};
use std::ops::Neg;
/// The mode in which a literal is expressed.
@@ -1497,7 +1497,8 @@ impl<'a> Assembler<'a> {
}
// And finally just push each byte from the given file as a fill bundle.
- for byte in file.bytes() {
+ let reader = BufReader::new(file);
+ for byte in reader.bytes() {
match byte {
Ok(b) => self.push_bundle(Bundle::fill(b), node)?,
Err(_) => break,