From 9269acf241386362667af461faae9b5936db40cb Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 29 Feb 2024 01:07:57 +0800 Subject: [PATCH] Refactor end calculation in main function --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 27bbb66..d789c83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,14 +91,14 @@ fn main() { // 将数据量处理成可被 thread_count 整除 let left = cli_arg.start % cli_arg.thread_count as u64; - cli_arg.end += left; + cli_arg.end = cli_arg.end.wrapping_add(left); let mut n = 0; let mut threads = Vec::with_capacity(cli_arg.thread_count as usize); for i in 0..cli_arg.thread_count { let top = cli_arg.top; - let max = cli_arg.end / cli_arg.thread_count as u64; + let max = cli_arg.end; n += 1; let thread_name = format!("thread_{}", i); let thread_count = cli_arg.thread_count;