Commit cd242fb4 authored by Ian Lance Taylor's avatar Ian Lance Taylor

Use the copy function rather than a loop.

R=r
CC=golang-dev
https://golang.org/cl/882047
parent d80c78b6
......@@ -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)]
......
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