Skip to content

Commit bb0c8dd

Browse files
authored
Replace custom AppendUint with strconv.AppendUint (#1813)
* Use strconv.AppendInt * Replace AppendInt with AppendUint * Fix typo
1 parent ed6a27a commit bb0c8dd

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

bytesconv.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io"
1111
"math"
1212
"net"
13+
"strconv"
1314
"sync"
1415
"time"
1516
)
@@ -127,21 +128,7 @@ func AppendUint(dst []byte, n int) []byte {
127128
panic("BUG: int must be positive")
128129
}
129130

130-
var b [20]byte
131-
buf := b[:]
132-
i := len(buf)
133-
var q int
134-
for n >= 10 {
135-
i--
136-
q = n / 10
137-
buf[i] = '0' + byte(n-q*10)
138-
n = q
139-
}
140-
i--
141-
buf[i] = '0' + byte(n)
142-
143-
dst = append(dst, buf[i:]...)
144-
return dst
131+
return strconv.AppendUint(dst, uint64(n), 10)
145132
}
146133

147134
// ParseUint parses uint from buf.

0 commit comments

Comments
 (0)