mirror of
https://github.com/golang/go
synced 2024-11-22 05:34:39 -07:00
strconv: slightly faster int conversion for GOARCH=386
benchmark old ns/op new ns/op delta strconv_test.BenchmarkFormatInt 12198 12031 -1.37% strconv_test.BenchmarkAppendInt 9268 9153 -1.24% strconv_test.BenchmarkFormatUint 3538 3429 -3.08% strconv_test.BenchmarkAppendUint 3133 3062 -2.27% No performance difference for GOARCH=amd64. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5488089
This commit is contained in:
parent
34c7765fe5
commit
6890afd9a3
@ -76,7 +76,7 @@ func formatBits(dst []byte, u uint64, base int, neg, append_ bool) (d []byte, s
|
|||||||
for u >= 100 {
|
for u >= 100 {
|
||||||
i -= 2
|
i -= 2
|
||||||
q := u / 100
|
q := u / 100
|
||||||
j := u - q*100
|
j := uintptr(u - q*100)
|
||||||
a[i+1] = digits01[j]
|
a[i+1] = digits01[j]
|
||||||
a[i+0] = digits10[j]
|
a[i+0] = digits10[j]
|
||||||
u = q
|
u = q
|
||||||
@ -84,7 +84,7 @@ func formatBits(dst []byte, u uint64, base int, neg, append_ bool) (d []byte, s
|
|||||||
if u >= 10 {
|
if u >= 10 {
|
||||||
i--
|
i--
|
||||||
q := u / 10
|
q := u / 10
|
||||||
a[i] = digits[u-q*10]
|
a[i] = digits[uintptr(u-q*10)]
|
||||||
u = q
|
u = q
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ func formatBits(dst []byte, u uint64, base int, neg, append_ bool) (d []byte, s
|
|||||||
b := uint64(base)
|
b := uint64(base)
|
||||||
for u >= b {
|
for u >= b {
|
||||||
i--
|
i--
|
||||||
a[i] = digits[u%b]
|
a[i] = digits[uintptr(u%b)]
|
||||||
u /= b
|
u /= b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user