Preallocate 512 byte buffer for JSON deserialization.

This commit is contained in:
messense 2018-02-24 13:24:59 +08:00 committed by Sergio Benitez
parent 1e08177f55
commit fa217082fd
1 changed files with 1 additions and 1 deletions

View File

@ -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>
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) {
// Error::io is private to serde_json. Do not use outside of Rocket.
return Err(SerdeError::io(io_err));