Skip to content

Commit e4187c9

Browse files
committed
Non SIMD - Updates changes from Heinz for similarity
The SIMD version changes were suggested here - simd-lite/simd-json#188 (comment)
1 parent 2349d82 commit e4187c9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ struct SIMDExample<'sin> {
1515

1616
fn main() {
1717
let data_file = File::open("/home/aj/deploy/rust/zcapjson/data/fake_data.json").unwrap();
18-
let reader = BufReader::new(data_file);
18+
let mut reader = BufReader::new(data_file);
1919

20-
for line in reader.lines() {
21-
let row: &mut str = &mut line.unwrap();
22-
let row: SIMDExample = serde_json::from_str(row).unwrap();
23-
match row.id {
24-
2807149942735425369 => println!("look ma! a match! - {}", row.id_str),
25-
_ => println!("No match yet"),
20+
let mut data = Vec::with_capacity(1024);
21+
22+
while reader.read_until(b'\n', &mut data).unwrap() > 0 {
23+
let row: SIMDExample = serde_json::from_slice(data.as_mut_slice()).unwrap();
24+
if row.id == 2807149942735425369 {
25+
println!("look ma! a match! - {}", row.id_str);
2626
}
27+
data.clear();
2728
}
2829
}

0 commit comments

Comments
 (0)