scx_rusty: Refactor ridx assignment in populate_tasks_by_load

Origin assignment of the variable ridx is equivalent to comparing
between "ridx" and "wids - MAX_PIDS". Using u64 max library helper
function to perform the comparison and provide better readability.

Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
This commit is contained in:
I Hsin Cheng 2024-06-23 21:58:51 +08:00
parent 5038f54701
commit eab234a74f

View File

@ -686,9 +686,7 @@ impl<'a, 'b> LoadBalancer<'a, 'b> {
let mut pids = vec![];
let (mut ridx, widx) = (active_pids.read_idx, active_pids.write_idx);
if widx - ridx > MAX_PIDS {
ridx = widx - MAX_PIDS;
}
ridx = ridx.max(widx - MAX_PIDS);
for idx in ridx..widx {
let pid = active_pids.pids[(idx % MAX_PIDS) as usize];