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
10 changes: 5 additions & 5 deletions crates/oxc_mangler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::iter;
use std::iter::{self, repeat_with};

use fixedbitset::FixedBitSet;
use itertools::Itertools;
Expand Down Expand Up @@ -373,10 +373,10 @@ impl Mangler {
allocator: &'a Allocator,
) -> Vec<'a, SlotFrequency<'a>> {
let root_scope_id = scoping.root_scope_id();
let mut frequencies = Vec::with_capacity_in(total_number_of_slots, allocator);
for _ in 0..total_number_of_slots {
frequencies.push(SlotFrequency::new(allocator));
}
let mut frequencies = Vec::from_iter_in(
repeat_with(|| SlotFrequency::new(allocator)).take(total_number_of_slots),
allocator,
);

for (symbol_id, slot) in slots.iter().copied().enumerate() {
let symbol_id = SymbolId::from_usize(symbol_id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::iter::repeat_with;

use oxc_allocator::{CloneIn, Vec};
use oxc_ast::{NONE, ast::*};
use oxc_ecmascript::constant_evaluation::DetermineValueType;
Expand Down Expand Up @@ -744,8 +746,8 @@ impl<'a> PeepholeOptimizations {
if n.value.fract() == 0.0 {
let n_int = n.value as usize;
if (1..=6).contains(&n_int) {
let elisions = std::iter::from_fn(|| {
Some(ArrayExpressionElement::Elision(ctx.ast.elision(n.span)))
let elisions = repeat_with(|| {
ArrayExpressionElement::Elision(ctx.ast.elision(n.span))
})
.take(n_int);
return Some(ctx.ast.expression_array(
Expand Down
Loading