refactor(ast): use loop instead of recursion (#5447)

Use loop instead of recursive function call. Loops are usually cheaper.
This commit is contained in:
overlookmotel 2024-09-05 01:24:59 +00:00
parent 6285a02274
commit a43e9512f3

View file

@ -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 {