From bb0c8dd79ca716f3e93d2ac5aac96b567eec3e2f Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:59:52 -0400 Subject: [PATCH] Replace custom AppendUint with strconv.AppendUint (#1813) * Use strconv.AppendInt * Replace AppendInt with AppendUint * Fix typo --- bytesconv.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/bytesconv.go b/bytesconv.go index dddf24f..f01a6c1 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -10,6 +10,7 @@ import ( "io" "math" "net" + "strconv" "sync" "time" ) @@ -127,21 +128,7 @@ func AppendUint(dst []byte, n int) []byte { panic("BUG: int must be positive") } - var b [20]byte - buf := b[:] - i := len(buf) - var q int - for n >= 10 { - i-- - q = n / 10 - buf[i] = '0' + byte(n-q*10) - n = q - } - i-- - buf[i] = '0' + byte(n) - - dst = append(dst, buf[i:]...) - return dst + return strconv.AppendUint(dst, uint64(n), 10) } // ParseUint parses uint from buf.