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

@ -124,7 +124,10 @@ impl super::Fetcher for GhCrateMeta {
return Ok(false);
};
let repo = repo.as_ref().map(|u| u.as_str().trim_end_matches('/'));
// Convert Option<Url> to Option<String> to reduce size of future.
let repo = repo.map(String::from);
let repo = repo.as_deref().map(|u| u.trim_end_matches('/'));
let launch_baseline_find_tasks = |pkg_fmt| {
match &pkg_urls {
Either::Left(pkg_url) => Either::Left(iter::once(*pkg_url)),