From 5e961163c40ef03adcc73b349a1052914e0199bb Mon Sep 17 00:00:00 2001 From: mos Date: Fri, 19 Apr 2024 11:07:42 +0200 Subject: [PATCH] improve memory initialization --- src/cpu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 88ac3ce..674b498 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -94,9 +94,9 @@ struct Instruction { impl Ram { fn new() -> Self { - let mut mem = Vec::new(); - mem.resize((RAM_SIZE - RAM_BASE) as usize, 0); - Self { mem } + Self { + mem: vec![0; (RAM_SIZE - RAM_BASE) as usize], + } } }