Skip to content

Commit

Permalink
refactor(transformer/class-properties): remove move_expressions (#7979
Browse files Browse the repository at this point in the history
)

Remove 2 x `move_expression` calls by taking value from `Option` instead. This avoids allocating dummy `Expression`s into arena.
  • Loading branch information
overlookmotel committed Dec 18, 2024
1 parent 94b376a commit ee282f8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/oxc_transformer/src/es2022/class_properties/prop_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
ctx: &mut TraverseCtx<'a>,
) {
// Get value
let value = match &mut prop.value {
Some(value) => {
self.transform_instance_initializer(value, ctx);
ctx.ast.move_expression(value)
let value = match prop.value.take() {
Some(mut value) => {
self.transform_instance_initializer(&mut value, ctx);
value
}
None => ctx.ast.void_0(SPAN),
};
Expand Down Expand Up @@ -90,10 +90,10 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
) {
// Get value, and transform it to replace `this` with reference to class name,
// and transform class fields (`object.#prop`)
let value = match &mut prop.value {
Some(value) => {
self.transform_static_initializer(value, ctx);
ctx.ast.move_expression(value)
let value = match prop.value.take() {
Some(mut value) => {
self.transform_static_initializer(&mut value, ctx);
value
}
None => ctx.ast.void_0(SPAN),
};
Expand Down

0 comments on commit ee282f8

Please sign in to comment.