Skip to content

Commit

Permalink
perf(codegen): slightly faster print_list
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 25, 2024
1 parent d22bd20 commit 33a7afe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/oxc_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ impl<'a> Codegen<'a> {
}

fn print_list<T: Gen>(&mut self, items: &[T], ctx: Context) {
for (index, item) in items.iter().enumerate() {
if index != 0 {
self.print_comma();
self.print_soft_space();
}
let mut iter = items.iter();
let Some(item) = iter.next() else { return };
item.gen(self, ctx);
for item in iter {
self.print_comma();
self.print_soft_space();
item.gen(self, ctx);
}
}
Expand Down

0 comments on commit 33a7afe

Please sign in to comment.