perf(transformer/arrow-function): stop traversal at function as super() can't appear in a nested function (#8383)

This commit is contained in:
Dunqing 2025-01-10 08:28:06 +08:00 committed by overlookmotel
parent fd35866141
commit 07edf74c58

View file

@ -1209,8 +1209,11 @@ impl<'a> VisitMut<'a> for ConstructorBodyThisAfterSuperInserter<'a, '_> {
}
}
}
// TODO: Stop traversal at a `Function` too. `super()` can't appear in a nested function,
// so no point traversing it. This is for performance, not correctness.
#[inline] // `#[inline]` because is a no-op
fn visit_function(&mut self, _func: &mut Function<'a>, _flags: ScopeFlags) {
// `super()` can't appear in a nested function
}
/// `super()` -> `super(); _this = this;`
fn visit_statements(&mut self, statements: &mut ArenaVec<'a, Statement<'a>>) {