Skip to content

Commit

Permalink
refactor(ast): use loop instead of recursion (#5447)
Browse files Browse the repository at this point in the history
Use loop instead of recursive function call. Loops are usually cheaper.
  • Loading branch information
overlookmotel committed Sep 5, 2024
1 parent 6285a02 commit a43e951
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ impl<'a> Expression<'a> {

/// Remove nested parentheses from this expression.
pub fn without_parenthesized(&self) -> &Self {
match self {
Expression::ParenthesizedExpression(expr) => expr.expression.without_parenthesized(),
_ => self,
let mut expr = self;
while let Expression::ParenthesizedExpression(paran_expr) = expr {
expr = &paran_expr.expression;
}
expr
}

pub fn is_specific_id(&self, name: &str) -> bool {
Expand Down

0 comments on commit a43e951

Please sign in to comment.