Skip to content
Merged
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
9 changes: 7 additions & 2 deletions crates/oxc_mangler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl Mangler {

// Stores the lived scope ids for each slot. Keyed by slot number.
let mut slot_liveness: std::vec::Vec<FixedBitSet> = vec![];
let mut tmp_bindings = std::vec::Vec::with_capacity(100);

let mut reusable_slots = std::vec::Vec::new();
// Walk down the scope tree and assign a slot number for each symbol.
Expand Down Expand Up @@ -217,8 +218,12 @@ impl Mangler {
}

// Sort `bindings` in declaration order.
let sorted_bindings = bindings.values().copied().sorted_unstable();
for (symbol_id, assigned_slot) in sorted_bindings.zip(reusable_slots.iter().copied()) {
tmp_bindings.clear();
tmp_bindings.extend(bindings.values().copied());
tmp_bindings.sort_unstable();
for (&symbol_id, assigned_slot) in
tmp_bindings.iter().zip(reusable_slots.iter().copied())
{
slots[symbol_id.index()] = assigned_slot;

// If the symbol is declared by `var`, then it can be hoisted to
Expand Down
Loading