Skip to content

Commit 0440b2f

Browse files
authored
Merge pull request #3994 from careworry/develop
refactor: use the built-in max/min to simplify the code
2 parents 7b9ace9 + 04ae3de commit 0440b2f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/apps/chifra/pkg/progress/scanbar.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ func (v *ScanBar) Report(writer io.Writer, action, msg string) {
4646
}
4747
width := int(float64(screenWidth()) * v.WidPct)
4848
done := int(float64(width) * v.Pct())
49-
remains := width - done
50-
if remains < 0 {
51-
remains = 0
52-
}
49+
remains := max(width-done, 0)
5350
w := int(screenWidth()) - 2
5451
x := fmt.Sprintf("%s [%s%s] %s", action, strings.Repeat(".", done), strings.Repeat(" ", remains), msg)
5552
x = x[0:min(len(x), w)]

0 commit comments

Comments
 (0)