From 49a6fdadf5d4c5234e3541fd8af427c79cc47a77 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 20 Aug 2025 01:16:07 +0000 Subject: [PATCH] refactor(transformer/decorator): re-order methods (#13219) Pure refactor. Re-order methods of `LegacyDecorator` to be in the order in which they're called during traversal. --- .../src/decorator/legacy/mod.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/oxc_transformer/src/decorator/legacy/mod.rs b/crates/oxc_transformer/src/decorator/legacy/mod.rs index a25e91334e76c..4e665c17ba047 100644 --- a/crates/oxc_transformer/src/decorator/legacy/mod.rs +++ b/crates/oxc_transformer/src/decorator/legacy/mod.rs @@ -111,6 +111,18 @@ impl<'a, 'ctx> LegacyDecorator<'a, 'ctx> { } impl<'a> Traverse<'a, TransformState<'a>> for LegacyDecorator<'a, '_> { + #[inline] + fn enter_class(&mut self, class: &mut Class<'a>, ctx: &mut TraverseCtx<'a>) { + if self.emit_decorator_metadata { + self.metadata.enter_class(class, ctx); + } + } + + #[inline] + fn exit_class(&mut self, class: &mut Class<'a>, ctx: &mut TraverseCtx<'a>) { + self.transform_class(class, ctx); + } + // `#[inline]` because this is a hot path #[inline] fn exit_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) { @@ -126,18 +138,6 @@ impl<'a> Traverse<'a, TransformState<'a>> for LegacyDecorator<'a, '_> { } } - #[inline] - fn exit_class(&mut self, class: &mut Class<'a>, ctx: &mut TraverseCtx<'a>) { - self.transform_class(class, ctx); - } - - #[inline] - fn enter_class(&mut self, class: &mut Class<'a>, ctx: &mut TraverseCtx<'a>) { - if self.emit_decorator_metadata { - self.metadata.enter_class(class, ctx); - } - } - #[inline] fn enter_method_definition( &mut self,