]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, strconv: tiny cleanups
authorRuss Cox <rsc@golang.org>
Tue, 4 May 2010 00:47:40 +0000 (17:47 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 4 May 2010 00:47:40 +0000 (17:47 -0700)
R=r
CC=golang-dev
https://golang.org/cl/1081042

src/pkg/runtime/slice.c
src/pkg/strconv/decimal.go

index d967b1669b9460480b5a99e137f051bc8d1a5ffe..4162b8daa27809b86274e8299b3ce5a0f846f1aa 100644 (file)
@@ -186,9 +186,7 @@ void
 void
 ·slicecopy(Slice to, Slice fm, uintptr width, int32 ret)
 {
-       if(fm.array == nil || fm.len == 0 ||
-          to.array == nil || to.len == 0 ||
-          width == 0) {
+       if(fm.len == 0 || to.len == 0 || width == 0) {
                ret = 0;
                goto out;
        }
index 3a7ebf926b72d092b40a37fcf289fe0b108b4c3d..b3348512f4a1ea5d7ed021c9273ac0ab018d68b6 100644 (file)
@@ -41,32 +41,25 @@ func (a *decimal) String() string {
                buf[w] = '.'
                w++
                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:
                // 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] = '.'
                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:
                // 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])
        }
        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 {
-       for i := 0; i < len(dst); i++ {
+       for i := range dst {
                dst[i] = '0'
        }
        return len(dst)