Skip to content

Commit

Permalink
perf(semantic): just need to find the AstKind::FormalParameter in is_…
Browse files Browse the repository at this point in the history
…in_formal_parameters (oxc-project#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">
  • Loading branch information
Dunqing authored Dec 29, 2023
1 parent 0e0f258 commit a743d06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
_ => {}
}
Expand Down

0 comments on commit a743d06

Please sign in to comment.