mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast): replace AstBuilder::move_statement_vec with move_vec (#4988)
Replace `AstBuilder::move_statement_vec` with a general `move_vec` method which handles any kind of `Vec`.
This commit is contained in:
parent
6ffbd78947
commit
cca7440d4b
2 changed files with 6 additions and 6 deletions
|
|
@ -82,11 +82,6 @@ impl<'a> AstBuilder<'a> {
|
||||||
mem::replace(stmt, Statement::EmptyStatement(self.alloc(empty_stmt)))
|
mem::replace(stmt, Statement::EmptyStatement(self.alloc(empty_stmt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn move_statement_vec(self, stmts: &mut Vec<'a, Statement<'a>>) -> Vec<'a, Statement<'a>> {
|
|
||||||
mem::replace(stmts, self.vec())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn move_assignment_target(self, target: &mut AssignmentTarget<'a>) -> AssignmentTarget<'a> {
|
pub fn move_assignment_target(self, target: &mut AssignmentTarget<'a>) -> AssignmentTarget<'a> {
|
||||||
let dummy = self.simple_assignment_target_identifier_reference(Span::default(), "");
|
let dummy = self.simple_assignment_target_identifier_reference(Span::default(), "");
|
||||||
|
|
@ -105,6 +100,11 @@ impl<'a> AstBuilder<'a> {
|
||||||
mem::replace(decl, empty_decl)
|
mem::replace(decl, empty_decl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn move_vec<T>(self, vec: &mut Vec<'a, T>) -> Vec<'a, T> {
|
||||||
|
mem::replace(vec, self.vec())
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------- Constructors ---------- */
|
/* ---------- Constructors ---------- */
|
||||||
|
|
||||||
/// `void 0`
|
/// `void 0`
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl<'a> TypeScript<'a> {
|
||||||
// every time a namespace declaration is encountered.
|
// every time a namespace declaration is encountered.
|
||||||
let mut new_stmts = self.ctx.ast.vec();
|
let mut new_stmts = self.ctx.ast.vec();
|
||||||
|
|
||||||
for stmt in self.ctx.ast.move_statement_vec(&mut program.body) {
|
for stmt in self.ctx.ast.move_vec(&mut program.body) {
|
||||||
match stmt {
|
match stmt {
|
||||||
Statement::TSModuleDeclaration(decl) => {
|
Statement::TSModuleDeclaration(decl) => {
|
||||||
if !decl.declare {
|
if !decl.declare {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue