]> Cypherpunks repositories - gostls13.git/commit
bytes: fix Replace so it actually copies
authorGustavo Niemeyer <gustavo@niemeyer.net>
Wed, 21 Sep 2011 15:36:17 +0000 (12:36 -0300)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Wed, 21 Sep 2011 15:36:17 +0000 (12:36 -0300)
commitd16ceca5c59c79c63f4847244d784ac49c944ff4
tree0fdcd1b02d2e88f6f2218b4fd00e34301d249e88
parent96f968df9ca9533b5f6bd04bc288a047e275b9a2
bytes: fix Replace so it actually copies

The documentation for bytes.Replace says it copies
the slice but it won't necessarily copy them.  Since
the data is mutable, breaking the contract is an issue.

We either have to fix this by making the copy at all
times, as suggested in this CL, or we should change the
documentation and perhaps make better use of the fact
it's fine to mutate the slice in place otherwise.

R=golang-dev, bradfitz, adg, rsc
CC=golang-dev
https://golang.org/cl/5081043
src/pkg/bytes/bytes.go
src/pkg/bytes/bytes_test.go