From 4b25dfc9b666e5f5c780c9cfa98e8ab0a4abb59d Mon Sep 17 00:00:00 2001 From: tjh <14987462+thomhayward@users.noreply.github.com> Date: Wed, 27 Nov 2024 22:44:27 +0000 Subject: [PATCH] remove `reclaim-memory` feature Always reclaim memory. It's faster. --- Cargo.toml | 3 +-- src/main.rs | 15 ++------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d11bae2..541be56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,5 @@ edition = "2021" smallvec = { version = "1.13.2" } [features] -default = ["reclaim-memory"] -reclaim-memory = [] +default = [] timing = [] diff --git a/src/main.rs b/src/main.rs index d7e83b6..d4b9b19 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,6 @@ pub struct Um<'a> { program_counter: Platter, registers: [Platter; 8], memory: Vec>, - #[cfg(feature = "reclaim-memory")] free_blocks: Vec, ops: Vec, stdin: Option<&'a mut dyn Read>, @@ -269,13 +268,6 @@ impl<'a> Um<'a> { &self.memory[0] } - #[cfg(not(feature = "reclaim-memory"))] - fn allocate_memory(&mut self, length: Platter) -> Platter { - self.memory.push(Self::new_block(length.into_index())); - (self.memory.len() - 1) as Platter - } - - #[cfg(feature = "reclaim-memory")] fn allocate_memory(&mut self, length: Platter) -> Platter { if let Some(index) = self.free_blocks.pop() { self.memory[index.into_index()] = Self::new_block(length.into_index()); @@ -288,11 +280,8 @@ impl<'a> Um<'a> { fn free_memory(&mut self, block: Platter) { assert!(block.into_index() < self.memory.len()); - #[cfg(feature = "reclaim-memory")] - { - self.free_blocks.push(block); - self.memory[block.into_index()] = Self::new_block(0); - } + self.free_blocks.push(block); + self.memory[block.into_index()] = Self::new_block(0); } fn new_block(len: usize) -> SmallVec<[Platter; SMALLVEC_SIZE]> { -- 2.54.0