aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-05-03 17:47:40 -0700
committerRuss Cox <rsc@golang.org>2010-05-03 17:47:40 -0700
commit7d7ebd2fe1ff7bc081accbadac1d80c5b6352624 (patch)
treec13c0a6c79b7f554c037774ab1d60beda13a1405
parenta9425c70aa85872371651a38209ef9db6acb8e35 (diff)
downloadgo-7d7ebd2fe1ff7bc081accbadac1d80c5b6352624.tar.gz
go-7d7ebd2fe1ff7bc081accbadac1d80c5b6352624.zip
runtime, strconv: tiny cleanups
R=r CC=golang-dev https://golang.org/cl/1081042
-rw-r--r--src/pkg/runtime/slice.c4
-rw-r--r--src/pkg/strconv/decimal.go17
2 files changed, 6 insertions, 15 deletions
diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c
index d967b1669b..4162b8daa2 100644
--- a/src/pkg/runtime/slice.c
+++ b/src/pkg/runtime/slice.c
@@ -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;
}
diff --git a/src/pkg/strconv/decimal.go b/src/pkg/strconv/decimal.go
index 3a7ebf926b..b3348512f4 100644
--- a/src/pkg/strconv/decimal.go
+++ b/src/pkg/strconv/decimal.go
@@ -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)