Commit 7d7ebd2f authored by Russ Cox's avatar Russ Cox

runtime, strconv: tiny cleanups

R=r
CC=golang-dev
https://golang.org/cl/1081042
parent a9425c70
...@@ -186,9 +186,7 @@ void ...@@ -186,9 +186,7 @@ void
void void
·slicecopy(Slice to, Slice fm, uintptr width, int32 ret) ·slicecopy(Slice to, Slice fm, uintptr width, int32 ret)
{ {
if(fm.array == nil || fm.len == 0 || if(fm.len == 0 || to.len == 0 || width == 0) {
to.array == nil || to.len == 0 ||
width == 0) {
ret = 0; ret = 0;
goto out; goto out;
} }
......
...@@ -41,32 +41,25 @@ func (a *decimal) String() string { ...@@ -41,32 +41,25 @@ func (a *decimal) String() string {
buf[w] = '.' buf[w] = '.'
w++ w++
w += digitZero(buf[w : w+-a.dp]) w += digitZero(buf[w : w+-a.dp])
w += copy(buf[w:w+a.nd], a.d[0:a.nd]) w += copy(buf[w:], a.d[0:a.nd])
case a.dp < a.nd: case a.dp < a.nd:
// decimal point in middle of digits // decimal point in middle of digits
w += copy(buf[w:w+a.dp], a.d[0:a.dp]) w += copy(buf[w:], a.d[0:a.dp])
buf[w] = '.' buf[w] = '.'
w++ w++
w += copy(buf[w:w+a.nd-a.dp], a.d[a.dp:a.nd]) w += copy(buf[w:], a.d[a.dp:a.nd])
default: default:
// zeros fill space between digits and decimal point // zeros fill space between digits and decimal point
w += copy(buf[w:w+a.nd], a.d[0:a.nd]) w += copy(buf[w:], a.d[0:a.nd])
w += digitZero(buf[w : w+a.dp-a.nd]) w += digitZero(buf[w : w+a.dp-a.nd])
} }
return string(buf[0:w]) return string(buf[0:w])
} }
func copy(dst []byte, src []byte) int {
for i := 0; i < len(dst); i++ {
dst[i] = src[i]
}
return len(dst)
}
func digitZero(dst []byte) int { func digitZero(dst []byte) int {
for i := 0; i < len(dst); i++ { for i := range dst {
dst[i] = '0' dst[i] = '0'
} }
return len(dst) return len(dst)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment