Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(transformer): StatementInjectorStore::insert_many_after ta…
…ke an iterator (#6856)

Follow-on after #6654.

Taking an `IntoIterator` avoids caller needing to construct a temporary `Vec`.
  • Loading branch information
overlookmotel committed Oct 24, 2024
commit 7339dde473a1694b0a842bc4342d0c5cc6306d58
5 changes: 4 additions & 1 deletion crates/oxc_transformer/src/common/statement_injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ impl<'a> StatementInjectorStore<'a> {
}

/// Add multiple statements to be inserted immediately after the target statement.
pub fn insert_many_after(&self, target: Address, stmts: Vec<Statement<'a>>) {
pub fn insert_many_after<S>(&self, target: Address, stmts: S)
where
S: IntoIterator<Item = Statement<'a>>,
{
let mut insertions = self.insertions.borrow_mut();
let adjacent_stmts = insertions.entry(target).or_default();
adjacent_stmts.extend(
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ impl<'a, 'ctx> Traverse<'a> for TypeScriptAnnotations<'a, 'ctx> {
stmt.address(),
self.assignments
.iter()
.map(|assignment| assignment.create_this_property_assignment(ctx))
.collect::<Vec<_>>(),
.map(|assignment| assignment.create_this_property_assignment(ctx)),
);
self.has_super_call = true;
}
Expand Down