Skip to content

Commit

Permalink
chore: move_statement_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Oct 7, 2023
1 parent abf31e9 commit 77c24da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/oxc_ast/src/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ impl<'a> AstBuilder<'a> {
mem::replace(stmt, empty_stmt)
}

pub fn move_statement_vec(&self, stmts: &mut Vec<'a, Statement<'a>>) -> Vec<'a, Statement<'a>> {
mem::replace(stmts, self.new_vec())
}

pub fn program(
&self,
span: Span,
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_transformer/src/es2022/class_static_block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::{ast::*, AstBuilder};
use oxc_span::{Atom, Span};

use std::{collections::HashSet, mem, ops::DerefMut, rc::Rc};
use std::{collections::HashSet, ops::DerefMut, rc::Rc};

/// ES2022: Class Static Block
///
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'a> ClassStaticBlock<'a> {
}
})
.unwrap_or_else(|| {
let statements = mem::replace(&mut block.body, self.ast.new_vec());
let statements = self.ast.move_statement_vec(&mut block.body);
let callee = self.ast.parenthesized_expression(
Span::default(),
self.ast.arrow_expression(
Expand Down

0 comments on commit 77c24da

Please sign in to comment.