Skip to content

Commit 456e1f7

Browse files
authored
refactor: passing vec length directly (#5050)
Refactor the constructor of ChunkGraph so that it directly accepts the module vector length.
1 parent da8dbad commit 456e1f7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/rolldown/src/chunk_graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use arcstr::ArcStr;
22
use oxc_index::{IndexVec, index_vec};
3-
use rolldown_common::{Chunk, ChunkIdx, ChunkTable, ModuleIdx, ModuleTable, SymbolRef};
3+
use rolldown_common::{Chunk, ChunkIdx, ChunkTable, ModuleIdx, SymbolRef};
44
use rustc_hash::FxHashMap;
55

66
#[derive(Debug)]
@@ -16,10 +16,10 @@ pub struct ChunkGraph {
1616
}
1717

1818
impl ChunkGraph {
19-
pub fn new(module_table: &ModuleTable) -> Self {
19+
pub fn new(modules_len: usize) -> Self {
2020
Self {
2121
chunk_table: ChunkTable::default(),
22-
module_to_chunk: index_vec![None; module_table.modules.len()],
22+
module_to_chunk: index_vec![None; modules_len],
2323
sorted_chunk_idx_vec: Vec::new(),
2424
entry_module_to_entry_chunk: FxHashMap::default(),
2525
safely_merge_cjs_ns_map_idx_vec: index_vec![],

crates/rolldown/src/stages/generate_stage/code_splitting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl GenerateStage<'_> {
4040
// If we are in test environment, to make the runtime module always fall into a standalone chunk,
4141
// we create a facade entry point for it.
4242

43-
let mut chunk_graph = ChunkGraph::new(&self.link_output.module_table);
43+
let mut chunk_graph = ChunkGraph::new(self.link_output.module_table.modules.len());
4444
chunk_graph.chunk_table.chunks.reserve(self.link_output.entries.len());
4545

4646
let mut index_splitting_info: IndexSplittingInfo = oxc_index::index_vec![SplittingInfo {

0 commit comments

Comments
 (0)