From 6564215f879a4f09deef407b10ebc4e5f4fb1100 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 31 Jul 2025 15:23:14 +0000 Subject: [PATCH] perf(semantic): remove check for `Program` when iterating ancestors (#12682) Tiny optimization. There's no need to check for `AstKind::Program` and break the loop, because the ancestors iterator already does this check. --- crates/oxc_semantic/src/checker/javascript.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index e7c7bd643d0be..219087390efcd 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -765,7 +765,7 @@ pub fn check_labeled_statement(stmt: &LabeledStatement, ctx: &SemanticBuilder<'_ for node_kind in ctx.nodes.ancestor_kinds(ctx.current_node_id) { match node_kind { // label cannot cross boundary on function or static block - AstKind::Function(_) | AstKind::StaticBlock(_) | AstKind::Program(_) => break, + AstKind::Function(_) | AstKind::StaticBlock(_) => break, // check label name redeclaration AstKind::LabeledStatement(label_stmt) if stmt.label.name == label_stmt.label.name => { return ctx.error(label_redeclaration(