Fold the leftover formatters into the SI ones and stop reallocating the draw scratch

This commit is contained in:
flamingcow
2026-08-04 13:37:19 -07:00
parent f5a6420cfa
commit 2035d42734
7 changed files with 42 additions and 60 deletions
-19
View File
@@ -71,25 +71,6 @@ func commas(v uint64) string {
return strings.Join(append([]string{s}, parts...), ",")
}
func commasInt(v int64) string {
if v < 0 {
return "-" + commas(uint64(-v))
}
return commas(uint64(v))
}
func humanBytes(b uint64) string {
const unit = 1000.0
v := float64(b)
for _, suffix := range []string{"B", "kB", "MB", "GB", "TB"} {
if v < unit {
return fmt.Sprintf("%.1f %s", v, suffix)
}
v /= unit
}
return fmt.Sprintf("%.1f PB", v)
}
// The magnitude letter goes with the figure so the unit can stay a fixed word
// on the label. Below a thousand no letter is left dangling, since a trailing
// space would push the figure off centre.