Skip to content

Commit

Permalink
refactor(ast): replace AstBuilder::move_statement_vec with move_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Aug 19, 2024
1 parent fbd5ec7 commit 3a32874
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ impl<'a> AstBuilder<'a> {
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]
pub fn move_assignment_target(self, target: &mut AssignmentTarget<'a>) -> AssignmentTarget<'a> {
let dummy = self.simple_assignment_target_identifier_reference(Span::default(), "");
Expand All @@ -127,6 +122,11 @@ impl<'a> AstBuilder<'a> {
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 ---------- */

/// `void 0`
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/typescript/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> TypeScript<'a> {
// every time a namespace declaration is encountered.
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 {
Statement::TSModuleDeclaration(decl) => {
if !decl.declare {
Expand Down

0 comments on commit 3a32874

Please sign in to comment.