Context
In crates/rolldown/src/stages/generate_stage/compute_cross_chunk_links.rs:237-282, the same 3-step canonical ref resolution pattern is duplicated 4 times within collect_depended_symbols:
// Pattern repeated 4 times:
let mut canonical_ref = symbols.canonical_ref_for(*referenced);
if let Some(namespace_alias) = &symbols.get(canonical_ref).namespace_alias {
canonical_ref = namespace_alias.namespace_ref;
}
depended_symbols.insert(canonical_ref);
Occurrences:
- Lines 237-241 — for
SymbolOrMemberExprRef::Symbol references
- Lines 248-253 — for
SymbolOrMemberExprRef::MemberExpr resolved references
- Lines 278-283 — for entry module resolved exports
- (potentially more in surrounding code)
Each occurrence performs 2 hash lookups per symbol reference: one for canonical_ref_for() and one for get() to check namespace_alias. This is called for every symbol in every statement in every module in every chunk.