mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Optimize Crates2Json::write_to_path
: Use to_writer
which avoids allocating a `Vec<u8>` just to hold serialized data. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d7ae1f242b
commit
c2ce265afa
1 changed files with 2 additions and 1 deletions
|
@ -60,7 +60,8 @@ impl Crates2Json {
|
|||
}
|
||||
|
||||
pub fn write_to_path(&self, path: impl AsRef<Path>) -> Result<(), Crates2JsonParseError> {
|
||||
fs::write(path, &serde_json::to_vec(&self)?)?;
|
||||
let file = fs::File::create(path.as_ref())?;
|
||||
serde_json::to_writer(file, &self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue