diff options
author | Ian Lance Taylor <iant@golang.org> | 2010-04-13 13:05:29 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2010-04-13 13:05:29 -0700 |
commit | 1fc0cd28e65617b7b184ea643c0bec3ccec26f65 (patch) | |
tree | b7b3df6006f553f06f0809e9576bda46df28eb01 /doc | |
parent | bde9219b3dc997b4b20324bb2b8d5b92d2a561c0 (diff) | |
download | golang-1fc0cd28e65617b7b184ea643c0bec3ccec26f65.tar.gz |
Use the copy function rather than a loop.
R=r
CC=golang-dev
http://codereview.appspot.com/882047
Diffstat (limited to 'doc')
-rw-r--r-- | doc/effective_go.html | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/doc/effective_go.html b/doc/effective_go.html index ce5fcb99d..415ae0962 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1070,10 +1070,8 @@ func Append(slice, data[]byte) []byte { if l + len(data) > cap(slice) { // reallocate // Allocate double what's needed, for future growth. newSlice := make([]byte, (l+len(data))*2) - // Copy data (could use bytes.Copy()). - for i, c := range slice { - newSlice[i] = c - } + // The copy function is predeclared and works for any slice type. + copy(newSlice, slice) slice = newSlice } slice = slice[0:l+len(data)] |