Skip to content

Commit

Permalink
Loop instead of recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Aug 31, 2019
1 parent 7bf25e8 commit 045f2ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,15 @@ impl Compiler {
let original_expr = mem::replace(expr, prelude_expr);

// Replace the 0 in the prelude with the actual expression
fn assign_last_body(l: &mut SpannedExpr<Symbol>, original_expr: SpannedExpr<Symbol>) {
match l.value {
ast::Expr::LetBindings(_, ref mut e) => {
assign_last_body(e, original_expr);
fn assign_last_body(mut l: &mut SpannedExpr<Symbol>, original_expr: SpannedExpr<Symbol>) {
loop {
match l.value {
ast::Expr::LetBindings(_, ref mut e) => l = e,
_ => {
*l = original_expr;
return;
}
}
_ => *l = original_expr,
}
}
assign_last_body(expr, original_expr);
Expand Down

0 comments on commit 045f2ed

Please sign in to comment.