speed up json read

This commit is contained in:
poma 2020-04-13 17:43:15 +03:00
parent d3cc6d3a5b
commit 3facfafe83
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657

@ -4,7 +4,7 @@ extern crate rand;
use std::str; use std::str;
use std::fs; use std::fs;
use std::fs::{OpenOptions, File}; use std::fs::{OpenOptions, File};
use std::io::{Read, Write}; use std::io::{Read, Write, BufReader};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::iter::repeat; use std::iter::repeat;
use std::sync::Arc; use std::sync::Arc;
@ -334,7 +334,7 @@ pub fn circuit_from_json_file<E: Engine>(filename: &str) -> CircomCircuit::<E> {
.read(true) .read(true)
.open(filename) .open(filename)
.expect("unable to open."); .expect("unable to open.");
return circuit_from_json(reader); return circuit_from_json(BufReader::new(reader));
} }
pub fn circuit_from_json<E: Engine, R: Read>(reader: R) -> CircomCircuit::<E> { pub fn circuit_from_json<E: Engine, R: Read>(reader: R) -> CircomCircuit::<E> {