mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 04:58:42 +00:00
Optimize Crates2Json::load_from_path
: Use from_reader
which avoids reading the entire file into string at once. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
fb3e35624b
commit
d7ae1f242b
1 changed files with 2 additions and 2 deletions
|
@ -47,8 +47,8 @@ impl Crates2Json {
|
|||
}
|
||||
|
||||
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, Crates2JsonParseError> {
|
||||
let file = fs::read_to_string(path)?;
|
||||
Ok(serde_json::from_str(&file)?)
|
||||
let file = fs::File::open(path.as_ref())?;
|
||||
Ok(serde_json::from_reader(file)?)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, cvs: CrateVersionSource, info: CrateInfo) {
|
||||
|
|
Loading…
Add table
Reference in a new issue