Skip to content

Commit 0ffeb14

Browse files
committed
Avoid unneeded computation on full progress bar
1 parent 611d629 commit 0ffeb14

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/term.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,13 @@ pub fn progress_bar<'a>(
227227

228228
if filled < width {
229229
stdout.write_all(b">")?;
230-
}
231230

232-
let width_minus_filled = width - filled;
233-
if width_minus_filled > 1 {
234-
let red_part_width = width_minus_filled - 1;
235-
stdout.queue(SetForegroundColor(Color::Red))?;
236-
for _ in 0..red_part_width {
237-
stdout.write_all(b"-")?;
231+
let width_minus_filled = width - filled;
232+
if width_minus_filled > 1 {
233+
stdout.queue(SetForegroundColor(Color::Red))?;
234+
for _ in 1..width_minus_filled {
235+
stdout.write_all(b"-")?;
236+
}
238237
}
239238
}
240239

0 commit comments

Comments
 (0)