mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Optimize Crates2Json
: Use String
as key
to avoid cost of deserializing (`CrateVersionSource::from_str`). Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
96aaca1cc6
commit
de9404feda
1 changed files with 2 additions and 2 deletions
|
@ -12,7 +12,7 @@ use super::CrateVersionSource;
|
|||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct Crates2Json {
|
||||
pub installs: BTreeMap<CrateVersionSource, CrateInfo>,
|
||||
pub installs: BTreeMap<String, CrateInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
|
@ -52,7 +52,7 @@ impl Crates2Json {
|
|||
}
|
||||
|
||||
pub fn insert(&mut self, cvs: CrateVersionSource, info: CrateInfo) {
|
||||
self.installs.insert(cvs, info);
|
||||
self.installs.insert(cvs.to_string(), info);
|
||||
}
|
||||
|
||||
pub fn write(&self) -> Result<(), Crates2JsonParseError> {
|
||||
|
|
Loading…
Add table
Reference in a new issue