Skip to content

Commit 07c833e

Browse files
committed
feat: add experimental simd-json support
Functionality is guarded by the `experimental-simdjson` feature flag. Signed-off-by: Sam Gammon <[email protected]>
1 parent 2dc8d9e commit 07c833e

File tree

4 files changed

+148
-3
lines changed

4 files changed

+148
-3
lines changed

Cargo.lock

Lines changed: 115 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ repository = "https://github.com/orogene/orogene"
7373
homepage = "https://orogene.dev"
7474
rust-version = "1.67.1"
7575

76+
[features]
77+
experimental-simdjson = ["nassun/experimental-simdjson"]
78+
7679
[workspace.dependencies]
7780
anyhow = "1.0.75"
7881
async-compression = "0.3.5"
@@ -134,6 +137,7 @@ sentry = "0.31.0"
134137
serde = "1.0.152"
135138
serde_json = "1.0.93"
136139
serde-wasm-bindgen = "0.4.5"
140+
simd-json = "0.14.3"
137141
ssri = "9.0.0"
138142
supports-unicode = "2.0.0"
139143
syn = "1.0.33"

crates/nassun/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ repository.workspace = true
1111
homepage.workspace = true
1212
rust-version.workspace = true
1313

14+
[features]
15+
experimental-simdjson = ["dep:simd-json"]
16+
1417
[dependencies]
1518
oro-common = { version = "=0.3.34", path = "../oro-common" }
1619
oro-client = { version = "=0.3.34", path = "../oro-client" }
@@ -31,6 +34,7 @@ node-semver = { workspace = true }
3134
once_cell = { workspace = true }
3235
serde = { workspace = true }
3336
serde_json = { workspace = true }
37+
simd-json = { workspace = true, features = ["serde_impl", "known-key"], optional = true }
3438
ssri = { workspace = true }
3539
thiserror = { workspace = true }
3640
tracing = { workspace = true }

crates/nassun/src/fetch/dir.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl DirFetcher {
2727
}
2828

2929
impl DirFetcher {
30+
#[cfg(not(feature = "experimental-simd-json"))]
3031
pub(crate) async fn corgi_manifest(&self, path: &Path) -> Result<Manifest> {
3132
let pkg_path = path.join("package.json");
3233
let json = async_std::fs::read(&pkg_path)
@@ -36,6 +37,8 @@ impl DirFetcher {
3637
serde_json::from_slice(&json[..]).map_err(NassunError::SerdeError)?;
3738
Ok(Manifest::Corgi(Box::new(pkgjson)))
3839
}
40+
41+
#[cfg(not(feature = "experimental-simd-json"))]
3942
pub(crate) async fn manifest(&self, path: &Path) -> Result<Manifest> {
4043
let pkg_path = path.join("package.json");
4144
let json = async_std::fs::read(&pkg_path)
@@ -46,6 +49,28 @@ impl DirFetcher {
4649
Ok(Manifest::FullFat(Box::new(pkgjson)))
4750
}
4851

52+
#[cfg(feature = "experimental-simd-json")]
53+
pub(crate) async fn corgi_manifest(&self, path: &Path) -> Result<Manifest> {
54+
let pkg_path = path.join("package.json");
55+
let mut json = async_std::fs::read(&pkg_path)
56+
.await
57+
.map_err(|err| NassunError::DirReadError(err, pkg_path))?;
58+
let pkgjson: CorgiManifest =
59+
simd_json::from_slice(&mut json[..]).map_err(NassunError::SerdeSimdError)?;
60+
Ok(Manifest::Corgi(Box::new(pkgjson)))
61+
}
62+
63+
#[cfg(feature = "experimental-simd-json")]
64+
pub(crate) async fn manifest(&self, path: &Path) -> Result<Manifest> {
65+
let pkg_path = path.join("package.json");
66+
let mut json = async_std::fs::read(&pkg_path)
67+
.await
68+
.map_err(|err| NassunError::DirReadError(err, pkg_path))?;
69+
let pkgjson: OroManifest =
70+
simd_json::from_slice(&mut json[..]).map_err(NassunError::SerdeSimdError)?;
71+
Ok(Manifest::FullFat(Box::new(pkgjson)))
72+
}
73+
4974
pub(crate) async fn name_from_path(&self, path: &Path) -> Result<String> {
5075
Ok(self
5176
.packument_from_path(path)

0 commit comments

Comments
 (0)