mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 13:38:43 +00:00
Optimize: Avoid creation of Arc<str>
for target
in `entry` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
758dab7d4f
commit
de7ecad32c
1 changed files with 17 additions and 13 deletions
30
src/main.rs
30
src/main.rs
|
@ -267,14 +267,6 @@ async fn entry() -> Result<()> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let desired_targets = desired_targets.get().await;
|
|
||||||
let target: Arc<str> = Arc::from(
|
|
||||||
desired_targets
|
|
||||||
.first()
|
|
||||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?
|
|
||||||
.as_str(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm {
|
let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm {
|
||||||
// Confirm
|
// Confirm
|
||||||
let mut resolutions = Vec::with_capacity(tasks.len());
|
let mut resolutions = Vec::with_capacity(tasks.len());
|
||||||
|
@ -292,7 +284,7 @@ async fn entry() -> Result<()> {
|
||||||
resolution,
|
resolution,
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
temp_dir_path.clone(),
|
temp_dir_path.clone(),
|
||||||
target.clone(),
|
desired_targets.clone(),
|
||||||
jobserver_client.clone(),
|
jobserver_client.clone(),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
@ -304,12 +296,19 @@ async fn entry() -> Result<()> {
|
||||||
.map(|task| {
|
.map(|task| {
|
||||||
let opts = opts.clone();
|
let opts = opts.clone();
|
||||||
let temp_dir_path = temp_dir_path.clone();
|
let temp_dir_path = temp_dir_path.clone();
|
||||||
let target = target.clone();
|
let desired_target = desired_targets.clone();
|
||||||
let jobserver_client = jobserver_client.clone();
|
let jobserver_client = jobserver_client.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let resolution = await_task(task).await?;
|
let resolution = await_task(task).await?;
|
||||||
install(resolution, opts, temp_dir_path, target, jobserver_client).await
|
install(
|
||||||
|
resolution,
|
||||||
|
opts,
|
||||||
|
temp_dir_path,
|
||||||
|
desired_target,
|
||||||
|
jobserver_client,
|
||||||
|
)
|
||||||
|
.await
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -548,7 +547,7 @@ async fn install(
|
||||||
resolution: Resolution,
|
resolution: Resolution,
|
||||||
opts: Arc<Options>,
|
opts: Arc<Options>,
|
||||||
temp_dir: Arc<Path>,
|
temp_dir: Arc<Path>,
|
||||||
target: Arc<str>,
|
desired_targets: DesiredTargets,
|
||||||
jobserver_client: jobserver::Client,
|
jobserver_client: jobserver::Client,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match resolution {
|
match resolution {
|
||||||
|
@ -566,6 +565,11 @@ async fn install(
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
Resolution::InstallFromSource { package } => {
|
Resolution::InstallFromSource { package } => {
|
||||||
|
let desired_targets = desired_targets.get().await;
|
||||||
|
let target = desired_targets
|
||||||
|
.first()
|
||||||
|
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
|
||||||
|
|
||||||
if !opts.dry_run {
|
if !opts.dry_run {
|
||||||
install_from_source(package, target, jobserver_client).await
|
install_from_source(package, target, jobserver_client).await
|
||||||
} else {
|
} else {
|
||||||
|
@ -679,7 +683,7 @@ async fn install_from_package(
|
||||||
|
|
||||||
async fn install_from_source(
|
async fn install_from_source(
|
||||||
package: Package<Meta>,
|
package: Package<Meta>,
|
||||||
target: Arc<str>,
|
target: &str,
|
||||||
jobserver_client: jobserver::Client,
|
jobserver_client: jobserver::Client,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
debug!(
|
debug!(
|
||||||
|
|
Loading…
Add table
Reference in a new issue