diff options
author | Russ Cox <rsc@golang.org> | 2010-05-03 17:47:40 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-05-03 17:47:40 -0700 |
commit | 7a01eb5345dec0273ae3ed2410d8034cde9cdb1d (patch) | |
tree | 7443eed383e1279dcd0fb5f0a01377daba5efbd6 /src/pkg/strconv | |
parent | 34a73ae805fe8332e7d6637777db7ee4ad8c9139 (diff) | |
download | golang-7a01eb5345dec0273ae3ed2410d8034cde9cdb1d.tar.gz |
runtime, strconv: tiny cleanups
R=r
CC=golang-dev
http://codereview.appspot.com/1081042
Diffstat (limited to 'src/pkg/strconv')
-rw-r--r-- | src/pkg/strconv/decimal.go | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/pkg/strconv/decimal.go b/src/pkg/strconv/decimal.go index 3a7ebf926..b3348512f 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) |