Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove SmallVec and LazyIndexMap from json value #184

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion crates/fuzz/fuzz_targets/compare_to_serde.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![no_main]
#![allow(clippy::dbg_macro)]

use indexmap::IndexMap;
use jiter::{JsonError as JiterError, JsonErrorType as JiterJsonErrorType, JsonValue as JiterValue};
use serde_json::{Error as SerdeError, Number as SerdeNumber, Value as SerdeValue};

Expand All @@ -27,10 +28,12 @@ pub fn values_equal(jiter_value: &JiterValue, serde_value: &SerdeValue) -> bool
true
}
(JiterValue::Object(o1), SerdeValue::Object(o2)) => {
// deduplicate, as `jiter` doesn't do this during parsing
let o1: IndexMap<_, _> = o1.iter().map(|(k, v)| (k, v)).collect();
if o1.len() != o2.len() {
return false;
}
for (k1, v1) in o1.iter_unique() {
for (k1, v1) in o1 {
if let Some(v2) = o2.get::<str>(k1.as_ref()) {
if !values_equal(v1, v2) {
return false;
Expand Down
32 changes: 1 addition & 31 deletions crates/jiter/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::hint::black_box;
use std::fs::File;
use std::io::Read;

use jiter::{Jiter, JsonValue, LazyIndexMap, PartialMode, Peek};
use jiter::{Jiter, JsonValue, PartialMode, Peek};
use serde_json::Value;

fn read_file(path: &str) -> String {
Expand Down Expand Up @@ -276,33 +276,6 @@ fn x100_serde_iter(bench: &mut Bencher) {
serde_str("./benches/x100.json", bench);
}

fn lazy_map_lookup(length: i64, bench: &mut Bencher) {
bench.iter(|| {
let mut map: LazyIndexMap<String, JsonValue> = LazyIndexMap::new();
for i in 0..length {
let key = i.to_string();
map.insert(key, JsonValue::Int(i));
}

// best case we get the next value each time
for i in 0..length {
black_box(map.get(&i.to_string()).unwrap());
}
})
}

fn lazy_map_lookup_1_10(bench: &mut Bencher) {
lazy_map_lookup(10, bench);
}

fn lazy_map_lookup_2_20(bench: &mut Bencher) {
lazy_map_lookup(20, bench);
}

fn lazy_map_lookup_3_50(bench: &mut Bencher) {
lazy_map_lookup(50, bench);
}

benchmark_group!(
benches,
big_jiter_iter,
Expand Down Expand Up @@ -360,9 +333,6 @@ benchmark_group!(
true_object_jiter_skip,
true_object_jiter_value,
true_object_serde_value,
lazy_map_lookup_1_10,
lazy_map_lookup_2_20,
lazy_map_lookup_3_50,
short_numbers_jiter_iter,
short_numbers_jiter_skip,
short_numbers_jiter_value,
Expand Down
174 changes: 0 additions & 174 deletions crates/jiter/src/lazy_index_map.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/jiter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@

mod errors;
mod jiter;
mod lazy_index_map;
mod number_decoder;
mod parse;
#[cfg(feature = "python")]
Expand All @@ -166,7 +165,6 @@ mod value;

pub use errors::{JiterError, JiterErrorType, JsonError, JsonErrorType, JsonResult, JsonType, LinePosition};
pub use jiter::{Jiter, JiterResult};
pub use lazy_index_map::LazyIndexMap;
pub use number_decoder::{NumberAny, NumberInt};
pub use parse::Peek;
pub use value::{JsonArray, JsonObject, JsonValue};
Expand Down
Loading
Loading