mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-17 12:56:09 +00:00
perf(transformer): skip expression exit pipeline for unaffected nodes
This commit is contained in:
1 parent
24f05550ad
commit
3d14714939
1 file changed
+26
-5
@@ -382,12 +382,22 @@ impl<'a> Traverse<'a, TransformState<'a>> for TransformerImpl<'a> {
|
||||
self.x4_regexp.enter_expression(expr, ctx);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn exit_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
self.common.exit_expression(expr, ctx);
|
||||
self.x1_jsx.exit_expression(expr, ctx);
|
||||
self.x2_es2022.exit_expression(expr, ctx);
|
||||
self.x2_es2018.exit_expression(expr, ctx);
|
||||
self.x2_es2017.exit_expression(expr, ctx);
|
||||
// The exit plugins only act on these expression kinds. Keep the no-op path in the walker.
|
||||
if matches!(
|
||||
expr,
|
||||
Expression::ArrowFunctionExpression(_)
|
||||
| Expression::AwaitExpression(_)
|
||||
| Expression::CallExpression(_)
|
||||
| Expression::ClassExpression(_)
|
||||
| Expression::FunctionExpression(_)
|
||||
| Expression::JSXElement(_)
|
||||
| Expression::JSXFragment(_)
|
||||
| Expression::YieldExpression(_)
|
||||
) {
|
||||
self.exit_expression_impl(expr, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
fn enter_simple_assignment_target(
|
||||
@@ -779,3 +789,14 @@ impl<'a> Traverse<'a, TransformState<'a>> for TransformerImpl<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TransformerImpl<'a> {
|
||||
#[inline(never)]
|
||||
fn exit_expression_impl(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
self.common.exit_expression(expr, ctx);
|
||||
self.x1_jsx.exit_expression(expr, ctx);
|
||||
self.x2_es2022.exit_expression(expr, ctx);
|
||||
self.x2_es2018.exit_expression(expr, ctx);
|
||||
self.x2_es2017.exit_expression(expr, ctx);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user