Skip to content

Commit

Permalink
address arvids comments about allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-o-how committed Feb 7, 2025
1 parent fa4523b commit 9a43216
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Allocator {

pub fn new_pair(&mut self, first: NodePtr, rest: NodePtr) -> Result<NodePtr, EvalErr> {
let idx = self.pair_vec.len();
if idx == MAX_NUM_PAIRS - self.num_ghost_pairs {
if idx > MAX_NUM_PAIRS - self.num_ghost_pairs {
return err(self.nil(), "too many pairs");
}
self.pair_vec.push(IntPair { first, rest });
Expand All @@ -356,11 +356,7 @@ impl Allocator {
if MAX_NUM_PAIRS - self.num_ghost_pairs - self.pair_vec.len() < amount {
return err(
self.nil(),
format!(
"reduce_pair_max: amount exceeds current pair count ({} pairs allocated, {} ghost pairs)",
self.pair_vec.len(),
self.num_ghost_pairs
).as_str(),
"too many pairs"
);
}
self.num_ghost_pairs += amount;
Expand Down

0 comments on commit 9a43216

Please sign in to comment.