Skip to content

Commit f9dae5c

Browse files
committed
refactor: use fmt.Appendf for improved performance
Signed-off-by: geogrego <geogrego@outlook.com>
1 parent acaebf8 commit f9dae5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

utils/math/prec_dec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,9 @@ func SortablePrecDecBytes(dec PrecDec) []byte {
771771
}
772772
// We move the negative sign to the front of all the left padded 0s, to make negative numbers come before positive numbers
773773
if dec.IsNegative() {
774-
return append([]byte("-"), []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.Abs().String()))...)
774+
return append([]byte("-"), fmt.Appendf(nil, fmt.Sprintf("%%0%ds", Precision*2+1), dec.Abs().String())...)
775775
}
776-
return []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.String()))
776+
return fmt.Appendf(nil, fmt.Sprintf("%%0%ds", Precision*2+1), dec.String())
777777
}
778778

779779
// reuse nil values

0 commit comments

Comments
 (0)