Avoid copying arguments for function calls.

This commit is contained in:
Stephen Chung
2020-05-03 16:54:24 +08:00
parent fc66a7ecef
commit d83b829810
8 changed files with 81 additions and 64 deletions

View File

@@ -371,12 +371,7 @@ fn optimize_expr<'a>(expr: Expr, state: &mut State<'a>) -> Expr {
(Expr::Variable(var, sp, _), Expr::Variable(var2, sp2, _)) if var == var2 && sp == sp2 => {
// Assignment to the same variable - fold
state.set_dirty();
Expr::Assignment(
Box::new(Expr::Variable(var, sp, pos)),
Box::new(optimize_expr(*expr2, state)),
pos,
)
Expr::Assignment(Box::new(Expr::Variable(var, sp, pos)), Box::new(optimize_expr(*expr2, state)), pos)
}
// id1 = id2 = expr2
(id1, id2) => Expr::Assignment(