perf(semantic): just need to find the AstKind::FormalParameter in is_in_formal_parameters (#1852)

A bit of performance improvement
<img width="894" alt="image"
src="https://github.com/oxc-project/oxc/assets/29533304/ed687532-df83-4bd8-a893-059e41c8adf3">
This commit is contained in:
Dunqing 2023-12-29 12:18:59 +08:00 committed by GitHub
parent 0e0f25872f
commit a743d06207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1089,7 +1089,7 @@ fn check_unary_expression<'a>(
fn is_in_formal_parameters<'a>(node: &AstNode<'a>, ctx: &SemanticBuilder<'a>) -> bool {
for node_id in ctx.nodes.ancestors(node.id()).skip(1) {
match ctx.nodes.kind(node_id) {
AstKind::FormalParameters(_) => return true,
AstKind::FormalParameter(_) => return true,
AstKind::Program(_) | AstKind::Function(_) | AstKind::ArrowExpression(_) => break,
_ => {}
}