More mionr optimizations (#553)

* Optimize `BinFile::preview_bin`: Use `Path::display` instead of `to_string_lossy` to avoid allocation.
* Refactor: Rm useless `AsRef::as_ref` call
* Optimize `GhCrateMeta::find`: Reduce fut size by converting `Url` to `String`
   `Url` is much larger than `String`.
* Refactor `PackageInfo::resolve`: Destruct `Meta::binstall`
* Optimize `resolve::load_manifest_path`: Avoid allocation

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-11-22 17:35:16 +11:00 committed by GitHub
parent 707b173de1
commit 66abf1b8c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 20 deletions

View file

@ -33,13 +33,14 @@ pub async fn fetch_crate_cratesio(
debug!("Looking up crate information");
// Fetch online crate information
let base_info = crates_io_api_client
.get_crate(name.as_ref())
.await
.map_err(|err| BinstallError::CratesIoApi {
crate_name: name.into(),
err: Box::new(err),
})?;
let base_info =
crates_io_api_client
.get_crate(name)
.await
.map_err(|err| BinstallError::CratesIoApi {
crate_name: name.into(),
err: Box::new(err),
})?;
// Locate matching version
let version_iter = base_info.versions.iter().filter(|v| !v.yanked);