]> Cypherpunks repositories - gostls13.git/commitdiff
bytes, strings: improve documentation for Count functions
authorRobert Griesemer <gri@golang.org>
Thu, 22 Jan 2015 17:16:20 +0000 (09:16 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 22 Jan 2015 18:28:35 +0000 (18:28 +0000)
Fixes #9659.

Change-Id: If364d5984a0c9a48858ae524b1560f633e621826
Reviewed-on: https://go-review.googlesource.com/3181
Reviewed-by: Rob Pike <r@golang.org>
src/bytes/bytes.go
src/strings/strings.go

index 7634707b3cb6e65e4d66cd7a5f295c0d476683c0..f24a071d14a03c2225ce3cfa1ff8e0d9d0cf4b54 100644 (file)
@@ -23,7 +23,7 @@ func equalPortable(a, b []byte) bool {
        return true
 }
 
-// explode splits s into a slice of UTF-8 sequences, one per Unicode character (still slices of bytes),
+// explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes),
 // up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes.
 func explode(s []byte, n int) [][]byte {
        if n <= 0 {
@@ -47,6 +47,7 @@ func explode(s []byte, n int) [][]byte {
 }
 
 // Count counts the number of non-overlapping instances of sep in s.
+// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s.
 func Count(s, sep []byte) int {
        n := len(sep)
        if n == 0 {
index 27d384983efb3626f62a4fd9ad60beebb106ef83..f362f185a9b2ae64b0cc4414084e91902e22b103 100644 (file)
@@ -78,6 +78,7 @@ func hashStrRev(sep string) (uint32, uint32) {
 }
 
 // Count counts the number of non-overlapping instances of sep in s.
+// If sep is an empty string, Count returns 1 + the number of Unicode code points in s.
 func Count(s, sep string) int {
        n := 0
        // special cases