fix: remove unnecessary allocation when loading boot rom
This commit is contained in:
parent
48ac8317a8
commit
c16f318fd1
|
@ -49,12 +49,9 @@ impl Default for Bus {
|
||||||
impl Bus {
|
impl Bus {
|
||||||
pub fn with_boot(path: &str) -> anyhow::Result<Self> {
|
pub fn with_boot(path: &str) -> anyhow::Result<Self> {
|
||||||
let mut file = File::open(path)?;
|
let mut file = File::open(path)?;
|
||||||
let mut buf = Vec::with_capacity(BOOT_ROM_SIZE);
|
let mut boot_rom = [0u8; 256];
|
||||||
file.read_to_end(&mut buf)?;
|
|
||||||
|
|
||||||
let boot_rom: [u8; BOOT_ROM_SIZE] = buf
|
file.read_exact(&mut boot_rom)?;
|
||||||
.try_into()
|
|
||||||
.map_err(|_| anyhow!("{} was not {} bytes in size", path, BOOT_ROM_SIZE))?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
boot: Some(boot_rom),
|
boot: Some(boot_rom),
|
||||||
|
|
Loading…
Reference in New Issue