mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
perf(transformer/class-properties): inline visitor methods (#7485)
Inline visitor methods in class properties transform.
This commit is contained in:
parent
24189f28ad
commit
5ca6eea77e
2 changed files with 10 additions and 0 deletions
|
|
@ -403,6 +403,8 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pop from private props stack.
|
/// 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) {
|
pub(super) fn transform_class_on_exit(&mut self, class: &Class) {
|
||||||
// Ignore TS class declarations
|
// Ignore TS class declarations
|
||||||
// TODO: Is this correct?
|
// TODO: Is this correct?
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,8 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'ctx> Traverse<'a> for 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>) {
|
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
|
// Note: `delete this.#prop` is an early syntax error, so no need to handle transforming it
|
||||||
match expr {
|
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(
|
fn enter_assignment_target(
|
||||||
&mut self,
|
&mut self,
|
||||||
target: &mut AssignmentTarget<'a>,
|
target: &mut AssignmentTarget<'a>,
|
||||||
|
|
@ -314,6 +318,8 @@ impl<'a, 'ctx> Traverse<'a> for ClassProperties<'a, 'ctx> {
|
||||||
self.transform_assignment_target(target, 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>) {
|
fn enter_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||||
match stmt {
|
match stmt {
|
||||||
// `class C {}`
|
// `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>) {
|
fn exit_class(&mut self, class: &mut Class<'a>, _ctx: &mut TraverseCtx<'a>) {
|
||||||
self.transform_class_on_exit(class);
|
self.transform_class_on_exit(class);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue