mirror of
https://github.com/golang/go
synced 2024-11-19 17:24:41 -07:00
big: removed some gratuitous +/-1's
R=mtj, bradfitz CC=golang-dev https://golang.org/cl/4584046
This commit is contained in:
parent
636c5fac2d
commit
2de06655f1
@ -764,13 +764,12 @@ func (x nat) string(charset string) string {
|
|||||||
if b == b&-b {
|
if b == b&-b {
|
||||||
// shift is base-b digit size in bits
|
// shift is base-b digit size in bits
|
||||||
shift := uint(trailingZeroBits(b)) // shift > 0 because b >= 2
|
shift := uint(trailingZeroBits(b)) // shift > 0 because b >= 2
|
||||||
m := len(x)
|
|
||||||
mask := Word(1)<<shift - 1
|
mask := Word(1)<<shift - 1
|
||||||
w := x[0]
|
w := x[0]
|
||||||
nbits := uint(_W) // number of unprocessed bits in w
|
nbits := uint(_W) // number of unprocessed bits in w
|
||||||
|
|
||||||
// convert less-significant words
|
// convert less-significant words
|
||||||
for k := 0; k < m-1; k++ {
|
for k := 1; k < len(x); k++ {
|
||||||
// convert full digits
|
// convert full digits
|
||||||
for nbits >= shift {
|
for nbits >= shift {
|
||||||
i--
|
i--
|
||||||
@ -782,16 +781,16 @@ func (x nat) string(charset string) string {
|
|||||||
// convert any partial leading digit and advance to next word
|
// convert any partial leading digit and advance to next word
|
||||||
if nbits == 0 {
|
if nbits == 0 {
|
||||||
// no partial digit remaining, just advance
|
// no partial digit remaining, just advance
|
||||||
w = x[k+1]
|
w = x[k]
|
||||||
nbits = _W
|
nbits = _W
|
||||||
} else {
|
} else {
|
||||||
// partial digit in current (k) and next (k+1) word
|
// partial digit in current (k-1) and next (k) word
|
||||||
w |= x[k+1] << nbits
|
w |= x[k] << nbits
|
||||||
i--
|
i--
|
||||||
s[i] = charset[w&mask]
|
s[i] = charset[w&mask]
|
||||||
|
|
||||||
// advance
|
// advance
|
||||||
w = x[k+1] >> (shift - nbits)
|
w = x[k] >> (shift - nbits)
|
||||||
nbits = _W - (shift - nbits)
|
nbits = _W - (shift - nbits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user