diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-06 19:49:01 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-06 19:49:01 +0000 |
commit | f038dae646bac2b31be98ab592c0e5206d2d96f5 (patch) | |
tree | 39530b071991b2326f881b2a30a2d82d6c133fd6 /libgo/go/bytes/bytes.go | |
parent | f20f261304993444741e0f0a14d3147e591bc660 (diff) | |
download | gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.zip gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.tar.gz gcc-f038dae646bac2b31be98ab592c0e5206d2d96f5.tar.bz2 |
libgo: Update to October 24 version of master library.
From-SVN: r204466
Diffstat (limited to 'libgo/go/bytes/bytes.go')
-rw-r--r-- | libgo/go/bytes/bytes.go | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go index e42f744..01a5d9ae 100644 --- a/libgo/go/bytes/bytes.go +++ b/libgo/go/bytes/bytes.go @@ -11,32 +11,6 @@ import ( "unicode/utf8" ) -// Compare returns an integer comparing two byte slices lexicographically. -// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. -// A nil argument is equivalent to an empty slice. -func Compare(a, b []byte) int { - m := len(a) - if m > len(b) { - m = len(b) - } - for i, ac := range a[0:m] { - bc := b[i] - switch { - case ac > bc: - return 1 - case ac < bc: - return -1 - } - } - switch { - case len(a) < len(b): - return -1 - case len(a) > len(b): - return 1 - } - return 0 -} - func equalPortable(a, b []byte) bool { if len(a) != len(b) { return false @@ -103,7 +77,7 @@ func Count(s, sep []byte) int { return count } -// Contains returns whether subslice is within b. +// Contains reports whether subslice is within b. func Contains(b, subslice []byte) bool { return Index(b, subslice) != -1 } @@ -401,10 +375,7 @@ func Repeat(b []byte, count int) []byte { nb := make([]byte, len(b)*count) bp := 0 for i := 0; i < count; i++ { - for j := 0; j < len(b); j++ { - nb[bp] = b[j] - bp++ - } + bp += copy(nb[bp:], b) } return nb } |