Declared variables prior to entering main conversion loops
This commit is contained in:
parent
d42c1e2bbc
commit
c38aeeb355
|
@ -87,7 +87,7 @@ func lettercode(digit rune) rune {
|
||||||
}
|
}
|
||||||
|
|
||||||
// adapt calculates next bias to be used for next iteration delta
|
// adapt calculates next bias to be used for next iteration delta
|
||||||
func adapt(delta rune, numpoints rune, firsttime bool) rune {
|
func adapt(delta rune, numpoints int, firsttime bool) rune {
|
||||||
if firsttime {
|
if firsttime {
|
||||||
delta /= _DAMP
|
delta /= _DAMP
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +95,7 @@ func adapt(delta rune, numpoints rune, firsttime bool) rune {
|
||||||
}
|
}
|
||||||
|
|
||||||
var k rune
|
var k rune
|
||||||
for delta = delta + delta/numpoints; delta > (_BASE-_MIN)*_MAX/2; k += _BASE {
|
for delta = delta + delta/rune(numpoints); delta > (_BASE-_MIN)*_MAX/2; k += _BASE {
|
||||||
delta /= _BASE - _MIN
|
delta /= _BASE - _MIN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,8 @@ func encodeBytes(input []byte) []byte {
|
||||||
basic = append(basic, byte(ltr))
|
basic = append(basic, byte(ltr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
basiclen := rune(len(basic))
|
basiclen := len(basic)
|
||||||
fulllen := rune(len(b))
|
fulllen := len(b)
|
||||||
if basiclen == fulllen {
|
if basiclen == fulllen {
|
||||||
return basic
|
return basic
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func encodeBytes(input []byte) []byte {
|
||||||
nextltr = next(b, n)
|
nextltr = next(b, n)
|
||||||
s.Truncate(0)
|
s.Truncate(0)
|
||||||
s.WriteRune(nextltr)
|
s.WriteRune(nextltr)
|
||||||
delta, n = delta+(nextltr-n)*(h+1), nextltr
|
delta, n = delta+(nextltr-n)*rune(h+1), nextltr
|
||||||
|
|
||||||
for _, ltr = range b {
|
for _, ltr = range b {
|
||||||
if ltr < n {
|
if ltr < n {
|
||||||
|
@ -225,9 +225,10 @@ func decodeBytes(b []byte) []byte {
|
||||||
return src
|
return src
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
i, oldi, w rune
|
i, oldi, w rune
|
||||||
ch byte
|
ch byte
|
||||||
t, digit, ln rune
|
t, digit rune
|
||||||
|
ln int
|
||||||
)
|
)
|
||||||
|
|
||||||
for i = 0; len(b) > 0; i++ {
|
for i = 0; len(b) > 0; i++ {
|
||||||
|
@ -247,10 +248,10 @@ func decodeBytes(b []byte) []byte {
|
||||||
|
|
||||||
w *= _BASE - t
|
w *= _BASE - t
|
||||||
}
|
}
|
||||||
ln = rune(len(out) + 1)
|
ln = len(out) + 1
|
||||||
bias = adapt(i-oldi, ln, oldi == 0)
|
bias = adapt(i-oldi, ln, oldi == 0)
|
||||||
n += i / ln
|
n += i / rune(ln)
|
||||||
i = i % ln
|
i = i % rune(ln)
|
||||||
// insert
|
// insert
|
||||||
out = append(out, 0)
|
out = append(out, 0)
|
||||||
copy(out[i+1:], out[i:])
|
copy(out[i+1:], out[i:])
|
||||||
|
|
Loading…
Reference in New Issue