mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 12:10:02 +00:00
Optimize use of tinytemplate
(#647)
* Optimize `GhCrateMeta::find`: Cache compiled template `pkg_url` * Optimize `collect_bin_files`: Cache compiled template `bin_dir` * Refactor: Improve readability of `gh_crate_meta` * Optimize `GhCrateMeta::launch_baseline_find_tasks`: Dedup urls before checking * Optimize `BinFile::new`: Avoid one heap alloc when creating `dest` * Improve `warn!` msg in `GhCrateMeta::launch_baseline_find_tasks` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
719b20aadd
commit
270bf08a24
3 changed files with 58 additions and 23 deletions
|
@ -12,6 +12,7 @@ use crates_io_api::AsyncClient as CratesIoApiClient;
|
|||
use itertools::Itertools;
|
||||
use maybe_owned::MaybeOwned;
|
||||
use semver::{Version, VersionReq};
|
||||
use tinytemplate::TinyTemplate;
|
||||
use tokio::task::block_in_place;
|
||||
use tracing::{debug, info, instrument, warn};
|
||||
|
||||
|
@ -297,11 +298,15 @@ fn collect_bin_files(
|
|||
.map(Cow::Borrowed)
|
||||
.unwrap_or_else(|| bins::infer_bin_dir_template(&bin_data));
|
||||
|
||||
let mut tt = TinyTemplate::new();
|
||||
|
||||
tt.add_template("bin_dir", &bin_dir)?;
|
||||
|
||||
// Create bin_files
|
||||
let bin_files = package_info
|
||||
.binaries
|
||||
.iter()
|
||||
.map(|bin| bins::BinFile::new(&bin_data, bin.name.as_str(), &bin_dir, no_symlinks))
|
||||
.map(|bin| bins::BinFile::new(&bin_data, bin.name.as_str(), &tt, no_symlinks))
|
||||
.collect::<Result<Vec<_>, BinstallError>>()?;
|
||||
|
||||
let mut source_set = BTreeSet::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue