Skip to content

Commit

Permalink
Avoid reallocating maps every loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tqn committed Mar 23, 2019
1 parent 398c7a9 commit 8e5bf85
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ where

pub fn reduce(&mut self) {
// could loop forever, like a running program
let mut symbols = Default::default();
let mut scope = Default::default();
loop {
let did_beta = self.beta_reduce();
self.make_identifiers_unique(&mut Default::default(), &mut Default::default());
self.make_identifiers_unique(&mut symbols, &mut scope);
let did_eta = self.eta_reduce();

if !did_beta && !did_eta {
break;
}

// clear the maps for memory reuse
symbols.clear();
scope.clear();
}
}

Expand Down

0 comments on commit 8e5bf85

Please sign in to comment.