mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(transformer/class-properties): remove move_expressions (#7979)
Remove 2 x `move_expression` calls by taking value from `Option` instead. This avoids allocating dummy `Expression`s into arena.
This commit is contained in:
parent
94b376a713
commit
ee282f8897
1 changed files with 8 additions and 8 deletions
|
|
@ -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),
|
||||
};
|
||||
|
|
@ -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),
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue