mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-25 06:40:03 +00:00
Minor optimization for bin and binstalk (#646)
* Refactor `logging`: Extract `report_err` * Optimize `get_default_pkg_url_template`: Return iter instead of `Vec` to avoid heap allocation. * Refactor `GhCrateMeta::find`: Rm `launch_baseline_find_tasks` * Optimize `GhCrateMeta::find`: Avoid cloning `Cow<'_, str>` * Improve `report_err` output: Print newline after msg Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
283163bbda
commit
eb95c5b799
3 changed files with 41 additions and 26 deletions
|
@ -44,7 +44,9 @@ impl RepositoryHost {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_default_pkg_url_template(self) -> Option<Vec<String>> {
|
||||
pub fn get_default_pkg_url_template(
|
||||
self,
|
||||
) -> Option<impl Iterator<Item = String> + Clone + 'static> {
|
||||
use RepositoryHost::*;
|
||||
|
||||
match self {
|
||||
|
@ -82,11 +84,14 @@ impl RepositoryHost {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply_filenames_to_paths(paths: &[&str], filenames: &[&[&str]], suffix: &str) -> Vec<String> {
|
||||
fn apply_filenames_to_paths(
|
||||
paths: &'static [&'static str],
|
||||
filenames: &'static [&'static [&'static str]],
|
||||
suffix: &'static str,
|
||||
) -> impl Iterator<Item = String> + Clone + 'static {
|
||||
filenames
|
||||
.iter()
|
||||
.flat_map(|fs| fs.iter())
|
||||
.cartesian_product(paths.iter())
|
||||
.map(|(filename, path)| format!("{path}/{filename}{suffix}"))
|
||||
.collect()
|
||||
.map(move |(filename, path)| format!("{path}/{filename}{suffix}"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue