Skip to content

Commit

Permalink
perf: incremental code splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng committed Sep 10, 2024
1 parent 27e328f commit 86f714c
Show file tree
Hide file tree
Showing 20 changed files with 1,314 additions and 639 deletions.
28 changes: 28 additions & 0 deletions .vscode/rspack.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"folders": [
{
"path": ".."
},
{
"path": "../../../demo/webpack"
},
{
"path": "../../webpack"
}
],
"settings": {
"git.ignoreLimitWarning": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.procMacro.attributes.enable": true,
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"crates/node_binding/Cargo.toml",
"./crates/rspack_plugin_ensure_chunk_conditions/Cargo.toml"
],
"files.associations": {
"*.snap": "markdown",
"*.snap.txt": "markdown",
"*.json": "jsonc"
}
}
}
19 changes: 19 additions & 0 deletions crates/rspack_collections/src/ukey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ where
self.inner.entry(id)
}

pub fn get(&self, id: &<Item as DatabaseItem>::ItemUkey) -> Option<&Item> {
self.inner.get(id)
}

pub fn get_mut(&mut self, id: &<Item as DatabaseItem>::ItemUkey) -> Option<&mut Item> {
self.inner.get_mut(id)
}

pub fn expect_get(&self, id: &<Item as DatabaseItem>::ItemUkey) -> &Item {
self
.inner
Expand Down Expand Up @@ -235,3 +243,14 @@ where
self.inner.entry(ukey).or_insert(item)
}
}

impl<Item: DatabaseItem> Database<Item>
where
<Item as DatabaseItem>::ItemUkey: Eq + Ord + Hash + Debug,
{
pub fn ordered_keys(&self) -> Vec<&<Item as DatabaseItem>::ItemUkey> {
let mut keys = self.keys().collect::<Vec<_>>();
keys.sort();
keys
}
}
Loading

0 comments on commit 86f714c

Please sign in to comment.