Avoid unneeded computation on full progress bar

This commit is contained in:
mo8it 2026-03-14 17:10:11 +01:00
parent 611d62951f
commit 0ffeb14402

View File

@ -227,16 +227,15 @@ pub fn progress_bar<'a>(
if filled < width {
stdout.write_all(b">")?;
}
let width_minus_filled = width - filled;
if width_minus_filled > 1 {
let red_part_width = width_minus_filled - 1;
stdout.queue(SetForegroundColor(Color::Red))?;
for _ in 0..red_part_width {
for _ in 1..width_minus_filled {
stdout.write_all(b"-")?;
}
}
}
stdout.queue(SetForegroundColor(Color::Reset))?;