perf(transformer/class-properties): inline visitor methods (#7485)

Inline visitor methods in class properties transform.
This commit is contained in:
overlookmotel 2024-11-26 11:36:09 +00:00
parent 24189f28ad
commit 5ca6eea77e
2 changed files with 10 additions and 0 deletions

View file

@ -403,6 +403,8 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
}
/// Pop from private props stack.
// `#[inline]` because this is function is so small
#[inline]
pub(super) fn transform_class_on_exit(&mut self, class: &Class) {
// Ignore TS class declarations
// TODO: Is this correct?

View file

@ -269,6 +269,8 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
}
impl<'a, 'ctx> Traverse<'a> for ClassProperties<'a, 'ctx> {
// `#[inline]` because this is a hot path
#[inline]
fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
// Note: `delete this.#prop` is an early syntax error, so no need to handle transforming it
match expr {
@ -306,6 +308,8 @@ impl<'a, 'ctx> Traverse<'a> for ClassProperties<'a, 'ctx> {
}
}
// `#[inline]` because this is a hot path
#[inline]
fn enter_assignment_target(
&mut self,
target: &mut AssignmentTarget<'a>,
@ -314,6 +318,8 @@ impl<'a, 'ctx> Traverse<'a> for ClassProperties<'a, 'ctx> {
self.transform_assignment_target(target, ctx);
}
// `#[inline]` because this is a hot path
#[inline]
fn enter_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) {
match stmt {
// `class C {}`
@ -340,6 +346,8 @@ impl<'a, 'ctx> Traverse<'a> for ClassProperties<'a, 'ctx> {
}
}
// `#[inline]` because `transform_class_on_exit` is so small
#[inline]
fn exit_class(&mut self, class: &mut Class<'a>, _ctx: &mut TraverseCtx<'a>) {
self.transform_class_on_exit(class);
}