mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Refactor: Avoid repeated heap alloc of temp_dir
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d514219ee4
commit
8ca85382af
1 changed files with 6 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
@ -315,9 +315,11 @@ async fn entry() -> Result<()> {
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let temp_dir_path = Arc::from(temp_dir.path());
|
||||||
|
|
||||||
let tasks: Vec<_> = resolutions
|
let tasks: Vec<_> = resolutions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|resolution| install(resolution, &opts, temp_dir.path(), &target))
|
.map(|resolution| install(resolution, &opts, &temp_dir_path, &target))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
|
@ -502,7 +504,7 @@ fn collect_bin_files(
|
||||||
fn install(
|
fn install(
|
||||||
resolution: Resolution,
|
resolution: Resolution,
|
||||||
opts: &Arc<Options>,
|
opts: &Arc<Options>,
|
||||||
temp_dir: &Path,
|
temp_dir: &Arc<Path>,
|
||||||
target: &Arc<str>,
|
target: &Arc<str>,
|
||||||
) -> tokio::task::JoinHandle<Result<()>> {
|
) -> tokio::task::JoinHandle<Result<()>> {
|
||||||
match resolution {
|
match resolution {
|
||||||
|
@ -518,7 +520,7 @@ fn install(
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
package,
|
package,
|
||||||
crate_name,
|
crate_name,
|
||||||
temp_dir.to_path_buf(),
|
Arc::clone(temp_dir),
|
||||||
version,
|
version,
|
||||||
bin_path,
|
bin_path,
|
||||||
bin_files,
|
bin_files,
|
||||||
|
@ -543,7 +545,7 @@ async fn install_from_package(
|
||||||
opts: Arc<Options>,
|
opts: Arc<Options>,
|
||||||
package: Package<Meta>,
|
package: Package<Meta>,
|
||||||
crate_name: CrateName,
|
crate_name: CrateName,
|
||||||
temp_dir: PathBuf,
|
temp_dir: Arc<Path>,
|
||||||
version: String,
|
version: String,
|
||||||
bin_path: PathBuf,
|
bin_path: PathBuf,
|
||||||
bin_files: Vec<bins::BinFile>,
|
bin_files: Vec<bins::BinFile>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue