Skip to content

Commit

Permalink
Merge 973d640 into b249c70
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser authored Mar 20, 2024
2 parents b249c70 + 973d640 commit fd3a0df
Show file tree
Hide file tree
Showing 30 changed files with 48 additions and 76 deletions.
6 changes: 0 additions & 6 deletions src/impls/avx2/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> __m256i {
_mm256_set1_epi8(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
#[target_feature(enable = "avx2")]
unsafe fn zero() -> __m256i {
_mm256_setzero_si256()
}
}
4 changes: 0 additions & 4 deletions src/impls/native/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> V128 {
u8x16_splat(n as u8)
}

unsafe fn zero() -> V128 {
u8x16_splat(0)
}
}
2 changes: 1 addition & 1 deletion src/impls/neon/deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ pub(crate) fn parse_str<'invoke, 'de>(
buffer: &'invoke mut [u8],
mut idx: usize,
) -> Result<&'de str> {
use ErrorType::{InvalidEscape, InvalidUnicodeCodepoint};
let input = input.input;

use ErrorType::{InvalidEscape, InvalidUnicodeCodepoint};
// Add 1 to skip the initial "
idx += 1;
//let mut read: usize = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/impls/neon/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> int8x16_t {
vdupq_n_s8(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> int8x16_t {
vdupq_n_s8(0)
}
}
5 changes: 0 additions & 5 deletions src/impls/portable/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,4 @@ impl Stage1Parse for SimdInput {
#[allow(clippy::cast_sign_loss)]
u8x64::splat(n as u8)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> u8x64 {
u8x64::splat(0)
}
}
5 changes: 0 additions & 5 deletions src/impls/simd128/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> v128 {
i8x16_splat(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> v128 {
i8x16_splat(0)
}
}
6 changes: 0 additions & 6 deletions src/impls/sse42/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> __m128i {
_mm_set1_epi8(n)
}

#[target_feature(enable = "sse4.2")]
#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> __m128i {
_mm_setzero_si128()
}
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ pub(crate) trait Stage1Parse {
}

unsafe fn fill_s8(n: i8) -> Self::SimdRepresentation;
unsafe fn zero() -> Self::SimdRepresentation;
}

/// Deserializer struct to deserialize a JSON
Expand Down Expand Up @@ -929,7 +928,7 @@ impl<'de> Deserializer<'de> {
self.idx += 1;
}

/// Same as next() but we pull out the check so we don't need to
/// Same as `next()` but we pull out the check so we don't need to
/// stry every time. Use this only if you know the next element exists!
///
/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ macro_rules! stry {
#[cfg(test)]
mod test {
use crate::prelude::*;
use crate::{json, json_typed, BorrowedValue, OwnedValue};
use crate::{BorrowedValue, OwnedValue};

#[cfg(feature = "serde_impl")]
fn owned_test_map() -> OwnedValue {
Expand Down
2 changes: 1 addition & 1 deletion src/numberparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn parse_eight_digits_unrolled(chars: &[u8]) -> u32 {
))]
#[allow(clippy::cast_ptr_alignment)]
fn parse_eight_digits_unrolled(chars: &[u8]) -> u32 {
let val = unsafe { (chars.as_ptr() as *const u64).read_unaligned() }; // memcpy(&val, chars, sizeof(u64));
let val = unsafe { chars.as_ptr().cast::<u64>().read_unaligned() }; // memcpy(&val, chars, sizeof(u64));
let val = (val & 0x0F0F_0F0F_0F0F_0F0F).wrapping_mul(2561) >> 8;
let val = (val & 0x00FF_00FF_00FF_00FF).wrapping_mul(6_553_601) >> 16;

Expand Down
11 changes: 7 additions & 4 deletions src/numberparse/correct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use super::{is_made_of_eight_digits_fast, parse_eight_digits_unrolled};
use crate::charutils::is_structural_or_whitespace;
use crate::error::Error;
use crate::safer_unchecked::GetSaferUnchecked;
use crate::unlikely;
use crate::StaticNode;
use crate::{static_cast_i64, Deserializer, ErrorType, Result};
use crate::{Deserializer, ErrorType, Result};

macro_rules! get {
($buf:ident, $idx:expr) => {
Expand Down Expand Up @@ -92,7 +91,9 @@ impl<'de> Deserializer<'de> {
idx += 1;
let first_after_period = idx as i64;
if is_integer(get!(buf, idx)) {
num = 10_u64.wrapping_mul(num) + u64::from(get!(buf, idx) - b'0');
num = 10_u64
.wrapping_mul(num)
.wrapping_add(u64::from(get!(buf, idx) - b'0'));
idx += 1;
} else {
err!(idx, get!(buf, idx))
Expand All @@ -111,7 +112,9 @@ impl<'de> Deserializer<'de> {
}
}
while is_integer(get!(buf, idx)) {
num = 10_u64.wrapping_mul(num) + u64::from(get!(buf, idx) - b'0');
num = 10_u64
.wrapping_mul(num)
.wrapping_add(u64::from(get!(buf, idx) - b'0'));
idx += 1;
}
exponent = first_after_period.wrapping_sub(idx as i64);
Expand Down
5 changes: 1 addition & 4 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ mod se;
mod value;
pub use self::se::*;
pub use self::value::*;
use crate::{stry, Buffers, Deserializer, Error, ErrorType, Result};
use crate::{stry, Buffers, Deserializer, Error, ErrorType, Node, Result};
use crate::{BorrowedValue, OwnedValue};
use crate::{Node, StaticNode};
use serde::de::DeserializeOwned;
use serde_ext::Deserialize;
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::io;
use value_trait::prelude::*;
Expand Down Expand Up @@ -483,7 +481,6 @@ mod test {
use serde::{Deserialize, Serialize};
use serde_json::{json as sjson, to_string as sto_string, Value as SerdeValue};
use std::collections::BTreeMap;
use std::convert::TryInto;

#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
struct UnitStruct;
Expand Down
2 changes: 1 addition & 1 deletion src/serde/de.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::serde_ext::de::IntoDeserializer;
use crate::{serde_ext, stry, Deserializer, Error, ErrorType, Node, Result, StaticNode};
use crate::{stry, Deserializer, Error, ErrorType, Node, Result, StaticNode};
use serde_ext::de::{self, DeserializeSeed, MapAccess, SeqAccess, Visitor};
use serde_ext::forward_to_deserialize_any;
use std::str;
Expand Down
3 changes: 1 addition & 2 deletions src/serde/se.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod pp;
use crate::{serde_ext, Error, ErrorType};
use crate::{Error, ErrorType};
pub use pp::*;
use serde_ext::ser;
use std::io::Write;
use std::result::Result;
use std::str;
use value_trait::generator::BaseGenerator;

Expand Down
3 changes: 1 addition & 2 deletions src/serde/se/pp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{serde_ext, stry, Error, ErrorType};
use crate::{stry, Error, ErrorType};
use serde_ext::ser;
use std::io::Write;
use std::result::Result;
use std::str;
use value_trait::generator::BaseGenerator;

Expand Down
1 change: 0 additions & 1 deletion src/serde/value/borrowed/de.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// A lot of this logic is a re-implementation or copy of serde_json::Value
use crate::Error;
use crate::ObjectHasher;
use crate::StaticNode;
use crate::{cow::Cow, ErrorType};
use crate::{
prelude::*,
Expand Down
2 changes: 1 addition & 1 deletion src/serde/value/borrowed/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ mod test {
use super::Value;
use crate::{borrowed::Object, serde::from_slice, ObjectHasher};
use serde::{Deserialize, Serialize};
use serde_json;
use value_trait::StaticNode;

#[test]
Expand Down Expand Up @@ -682,6 +681,7 @@ mod test {
struct Map {
key: u32,
}
#[allow(clippy::struct_field_names)]
#[derive(Deserialize, Serialize, PartialEq, Debug, Default)]
struct Obj {
v_i128: i128,
Expand Down
1 change: 0 additions & 1 deletion src/serde/value/owned/de.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A lot of this logic is a re-implementation or copy of serde_json::Value
use crate::ErrorType;
use crate::StaticNode;
use crate::{
prelude::*,
serde::value::shared::MapKeyDeserializer,
Expand Down
2 changes: 1 addition & 1 deletion src/serde/value/owned/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ mod test {
#[cfg(not(target_arch = "wasm32"))]
use crate::serde::{from_str, to_string};
use serde::{Deserialize, Serialize};
use serde_json;

#[derive(Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
struct UnitStruct;
Expand Down Expand Up @@ -618,6 +617,7 @@ mod test {
#[derive(Debug, Serialize, Deserialize)]
struct TestPoint(f64, f64);

#[allow(clippy::struct_field_names)]
#[derive(Deserialize, Serialize, PartialEq, Debug, Default)]
struct Obj {
v_i128: i128,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ proptest! {
.. ProptestConfig::default()
})]
#[test]
// #[allow(clippy::should_panic_without_expect)]
#[allow(clippy::should_panic_without_expect)]
#[should_panic]
fn prop_junk(d in arb_junk()) {
let mut d1 = d.clone();
Expand All @@ -947,7 +947,7 @@ proptest! {
})]

#[test]
// #[allow(clippy::should_panic_without_expect)]
#[allow(clippy::should_panic_without_expect)]
#[should_panic]
fn prop_string(d in "\\PC*") {
let mut d1 = d.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/value/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod serialize;
use super::ObjectHasher;
use crate::cow::Cow;
use crate::{prelude::*, Buffers};
use crate::{Deserializer, Node, Result, StaticNode};
use crate::{Deserializer, Node, Result};
use halfbrown::HashMap;
use std::fmt;
use std::ops::{Index, IndexMut};
Expand Down
1 change: 0 additions & 1 deletion src/value/borrowed/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::{Object, Value};
use crate::cow::Cow;
use crate::OwnedValue;
use crate::StaticNode;
use std::iter::FromIterator;

impl<'value> From<OwnedValue> for Value<'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
Expand Down
5 changes: 1 addition & 4 deletions src/value/borrowed/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

use super::{Object, Value};
use crate::prelude::*;
use crate::stry;
use crate::StaticNode;
use std::io;
use std::io::Write;
use value_trait::generator::{
BaseGenerator, DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
};

//use util::print_dec;
Expand Down Expand Up @@ -235,7 +233,6 @@ where
mod test {
use super::Value;
use crate::prelude::*;
use crate::StaticNode;

#[test]
fn null() {
Expand Down
2 changes: 1 addition & 1 deletion src/value/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod serialize;

use super::ObjectHasher;
use crate::{prelude::*, Buffers};
use crate::{Deserializer, Node, Result, StaticNode};
use crate::{Deserializer, Node, Result};
use halfbrown::HashMap;
use std::fmt;
use std::ops::{Index, IndexMut};
Expand Down
1 change: 0 additions & 1 deletion src/value/owned/from.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::{Object, Value};
use crate::{BorrowedValue, StaticNode};
use std::iter::FromIterator;

impl From<crate::BorrowedValue<'_>> for Value {
#[cfg_attr(not(feature = "no-inline"), inline)]
Expand Down
5 changes: 2 additions & 3 deletions src/value/owned/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

use super::{Object, Value};
use crate::prelude::*;
use crate::{stry, StaticNode};
use std::io;
use std::io::Write;
use value_trait::generator::{
BaseGenerator, DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
};

//use util::print_dec;
Expand Down Expand Up @@ -236,7 +235,7 @@ where
mod test {
use super::Value;
use crate::prelude::*;
use crate::StaticNode;

#[test]
fn null() {
assert_eq!(Value::Static(StaticNode::Null).encode(), "null");
Expand Down
20 changes: 14 additions & 6 deletions src/value/tape/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ pub struct Array<'tape, 'input>(pub(super) &'tape [Node<'input>]);

pub struct ArrayIter<'tape, 'input>(&'tape [Node<'input>]);

impl<'tape, 'input> Iterator for ArrayIter<'tape, 'input> {
type Item = Value<'tape, 'input>;

fn next(&mut self) -> Option<Self::Item> {
let (head, tail) = self.0.split_at(self.0.first()?.count());
self.0 = tail;
Some(Value(head))
}
}

// value_trait::Array for
impl<'tape, 'input> Array<'tape, 'input>
where
Expand Down Expand Up @@ -48,13 +58,11 @@ where
}
}

impl<'tape, 'input> Iterator for ArrayIter<'tape, 'input> {
impl<'tape, 'input> IntoIterator for &Array<'tape, 'input> {
type IntoIter = ArrayIter<'tape, 'input>;
type Item = Value<'tape, 'input>;

fn next(&mut self) -> Option<Self::Item> {
let (head, tail) = self.0.split_at(self.0.first()?.count());
self.0 = tail;
Some(Value(head))
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/value/tape/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ where
if object.len() != other.len() {
return false;
}
for (key, value) in object.iter() {
for (key, value) in &object {
if !other.get(key).map_or(false, |v| v == &value) {
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/value/tape/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ impl<'tape, 'input> Object<'tape, 'input> {
}
}

impl<'tape, 'input> IntoIterator for &Object<'tape, 'input> {
type IntoIter = ObjectIter<'tape, 'input>;
type Item = (&'input str, Value<'tape, 'input>);
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

impl<'tape, 'input> Iterator for ObjectIter<'tape, 'input> {
type Item = (&'input str, Value<'tape, 'input>);

Expand Down
Loading

0 comments on commit fd3a0df

Please sign in to comment.