]> Cypherpunks repositories - gostls13.git/commitdiff
doc: simplify Append example in "Effective Go"
authorGabriel Aszalos <gabriel.aszalos@gmail.com>
Mon, 18 Sep 2017 14:51:15 +0000 (16:51 +0200)
committerRob Pike <r@golang.org>
Tue, 19 Sep 2017 00:48:10 +0000 (00:48 +0000)
Change-Id: I011486993b167e65c69da1c8390bbcc625ca58c3
Reviewed-on: https://go-review.googlesource.com/64331
Reviewed-by: Rob Pike <r@golang.org>
doc/effective_go.html

index 731959e408a9012261b6985740a834da3bb53db4..6d53eefbc3d24a20b879ffe4228cee519a00740a 100644 (file)
@@ -1431,9 +1431,7 @@ func Append(slice, data []byte) []byte {
         slice = newSlice
     }
     slice = slice[0:l+len(data)]
-    for i, c := range data {
-        slice[l+i] = c
-    }
+    copy(slice[l:], data)
     return slice
 }
 </pre>