Skip to content

Commit 4bd2d17

Browse files
committed
Refactor thread count calculation in main function to use 80% of available CPU cores, ensuring a more efficient default setting.
1 parent 033fc4b commit 4bd2d17

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,13 @@ fn delete_target(target: &Path, threads: usize, use_trash: bool, quiet: bool, fo
402402
fn main() -> ! {
403403
let args = Args::parse();
404404

405-
let threads = args.threads.unwrap_or_else(num_cpus::get).clamp(1, 256);
405+
let threads = args
406+
.threads
407+
.unwrap_or_else(|| {
408+
let total = num_cpus::get();
409+
((total as f64 * 0.8).floor() as usize).max(1)
410+
})
411+
.clamp(1, 256);
406412

407413
if !args.quiet {
408414
eprintln!("Using {} thread(s)", threads);

0 commit comments

Comments
 (0)