Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@
- uses: dtolnay/rust-toolchain@nightly
- run: ./scripts/test.sh

miri:
name: Miri
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'CI' step
Uses Step
uses 'dtolnay/rust-toolchain' with ref 'nightly', not a pinned commit hash
with:
components: miri
- name: Run Miri
run: cargo miri test --all-features --lib

clippy_lint:
name: Format check
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:

jobs:
dependency-review:
runs-on: [self-hosted, Linux, amd64]
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.cursor/
.claude/
tmp/
target/
build/
.vscode/
Expand All @@ -12,4 +15,4 @@ Cargo.lock
*.profdata
*.svg
*.diff
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum JsonSlice<'de> {

impl<'de> JsonSlice<'de> {
#[inline(always)]
pub(crate) unsafe fn as_faststr(&self) -> FastStr {
pub(crate) fn as_faststr(&self) -> FastStr {
match self {
JsonSlice::Raw(sub) => FastStr::new(as_str(sub)),
JsonSlice::FastStr(f) => f.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/lazyvalue/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
let slice = json.to_u8_slice();
let reader = Read::new(slice, false);
let mut parser = Parser::new(reader);
let (sub, status) = parser.get_from_with_iter_unchecked(path)?;
let (sub, status) = parser.get_from_with_iter(path, false)?;
Ok(LazyValue::new(json.from_subset(sub), status.into()))
}

Expand Down Expand Up @@ -403,7 +403,7 @@ where
let slice = json.to_u8_slice();
let reader = Read::new(slice, false);
let mut parser = Parser::new(reader);
let (sub, status) = parser.get_from_with_iter(path)?;
let (sub, status) = parser.get_from_with_iter(path, true)?;
let lv = LazyValue::new(json.from_subset(sub), status.into());

// validate the utf-8 if slice
Expand Down
18 changes: 3 additions & 15 deletions src/lazyvalue/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,7 @@ impl JsonContainerTrait for OwnedLazyValue {
#[inline]
fn as_array(&self) -> Option<&Self::ArrayType> {
let parsed = match &self.0 {
LazyPacked::Raw(raw) => {
if raw.get_type() == JsonType::Array {
raw.load().ok()?
} else {
return None;
}
}
LazyPacked::Raw(raw) if raw.get_type() == JsonType::Array => raw.load().ok()?,
LazyPacked::Parsed(parsed) => parsed,
_ => return None,
};
Expand All @@ -521,13 +515,7 @@ impl JsonContainerTrait for OwnedLazyValue {
#[inline]
fn as_object(&self) -> Option<&Self::ObjectType> {
let parsed = match &self.0 {
LazyPacked::Raw(raw) => {
if raw.get_type() == JsonType::Object {
raw.load().ok()?
} else {
return None;
}
}
LazyPacked::Raw(raw) if raw.get_type() == JsonType::Object => raw.load().ok()?,
LazyPacked::Parsed(parsed) => parsed,
_ => return None,
};
Expand Down Expand Up @@ -590,7 +578,7 @@ impl OwnedLazyValue {

impl<'de> From<LazyValue<'de>> for OwnedLazyValue {
fn from(lv: LazyValue<'de>) -> Self {
let raw = unsafe { lv.raw.as_faststr() };
let raw = lv.raw.as_faststr();
if lv.inner.no_escaped() && raw.as_bytes()[0] == b'"' {
return Self(LazyPacked::NonEscStrRaw(raw));
}
Expand Down
Loading
Loading