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(),
|
||||
);
|
||||
|
||||
let temp_dir_path = Arc::from(temp_dir.path());
|
||||
|
||||
let tasks: Vec<_> = resolutions
|
||||
.into_iter()
|
||||
.map(|resolution| install(resolution, &opts, temp_dir.path(), &target))
|
||||
.map(|resolution| install(resolution, &opts, &temp_dir_path, &target))
|
||||
.collect();
|
||||
|
||||
for task in tasks {
|
||||
|
@ -502,7 +504,7 @@ fn collect_bin_files(
|
|||
fn install(
|
||||
resolution: Resolution,
|
||||
opts: &Arc<Options>,
|
||||
temp_dir: &Path,
|
||||
temp_dir: &Arc<Path>,
|
||||
target: &Arc<str>,
|
||||
) -> tokio::task::JoinHandle<Result<()>> {
|
||||
match resolution {
|
||||
|
@ -518,7 +520,7 @@ fn install(
|
|||
opts.clone(),
|
||||
package,
|
||||
crate_name,
|
||||
temp_dir.to_path_buf(),
|
||||
Arc::clone(temp_dir),
|
||||
version,
|
||||
bin_path,
|
||||
bin_files,
|
||||
|
@ -543,7 +545,7 @@ async fn install_from_package(
|
|||
opts: Arc<Options>,
|
||||
package: Package<Meta>,
|
||||
crate_name: CrateName,
|
||||
temp_dir: PathBuf,
|
||||
temp_dir: Arc<Path>,
|
||||
version: String,
|
||||
bin_path: PathBuf,
|
||||
bin_files: Vec<bins::BinFile>,
|
||||
|
|
Loading…
Add table
Reference in a new issue