mirror of https://github.com/rwf2/Rocket.git
Preallocate 512 byte buffer for JSON deserialization.
This commit is contained in:
parent
1e08177f55
commit
fa217082fd
|
@ -21,7 +21,7 @@ pub use serde_json::error::Error as SerdeError;
|
||||||
fn from_reader_eager<R, T>(mut reader: R) -> serde_json::Result<T>
|
fn from_reader_eager<R, T>(mut reader: R) -> serde_json::Result<T>
|
||||||
where R: Read, T: DeserializeOwned
|
where R: Read, T: DeserializeOwned
|
||||||
{
|
{
|
||||||
let mut s = String::new();
|
let mut s = String::with_capacity(512);
|
||||||
if let Err(io_err) = reader.read_to_string(&mut s) {
|
if let Err(io_err) = reader.read_to_string(&mut s) {
|
||||||
// Error::io is private to serde_json. Do not use outside of Rocket.
|
// Error::io is private to serde_json. Do not use outside of Rocket.
|
||||||
return Err(SerdeError::io(io_err));
|
return Err(SerdeError::io(io_err));
|
||||||
|
|
Loading…
Reference in New Issue