aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/bytes/bytes.go
diff options
context:
space:
mode:
authorCaleb Spare <cespare@gmail.com>2014-08-25 14:42:27 -0700
committerRob Pike <r@golang.org>2014-08-25 14:42:27 -0700
commit2c121b68b1c39f0a36546db2457d34e18c4bf73a (patch)
tree8eb175435ea957a79efd86314982f064d196e79f /src/pkg/bytes/bytes.go
parent958a6101eb75747555b2d5596de9ed93a54b83df (diff)
downloadgo-2c121b68b1c39f0a36546db2457d34e18c4bf73a.tar.xz
strings, bytes: document behavior of Replace when old is empty
Fixes #8143. LGTM=r R=rsc, bradfitz, r CC=golang-codereviews https://golang.org/cl/135760043
Diffstat (limited to 'src/pkg/bytes/bytes.go')
-rw-r--r--src/pkg/bytes/bytes.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go
index d8b6f998b3..34c22bbfb1 100644
--- a/src/pkg/bytes/bytes.go
+++ b/src/pkg/bytes/bytes.go
@@ -605,6 +605,9 @@ func Runes(s []byte) []rune {
// Replace returns a copy of the slice s with the first n
// non-overlapping instances of old replaced by new.
+// If old is empty, it matches at the beginning of the slice
+// and after each UTF-8 sequence, yielding up to k+1 replacements
+// for a k-rune slice.
// If n < 0, there is no limit on the number of replacements.
func Replace(s, old, new []byte, n int) []byte {
m := 0