Skip to content

Commit

Permalink
fix: Optimize parser (#869)
Browse files Browse the repository at this point in the history
* Clone expression parser instead of using exponential recursion

* Remove redundant clone
  • Loading branch information
jfecher authored Feb 17, 2023
1 parent 5eddaf7 commit e927a39
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions crates/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,12 @@ where
let next_precedence =
if is_type_expression { precedence.next_type_precedence() } else { precedence.next() };

expression_with_precedence(precedence.next(), expr_parser.clone(), is_type_expression)
.then(
then_commit(
operator_with_precedence(precedence),
expression_with_precedence(next_precedence, expr_parser, is_type_expression),
)
.repeated(),
)
let next_expr =
expression_with_precedence(next_precedence, expr_parser, is_type_expression);

next_expr
.clone()
.then(then_commit(operator_with_precedence(precedence), next_expr).repeated())
.foldl(create_infix_expression)
.boxed()
.labelled("expression")
Expand Down

0 comments on commit e927a39

Please sign in to comment.