Fold the leftover formatters into the SI ones and stop reallocating the draw scratch
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user