diff options
| author | Keith Randall <khr@golang.org> | 2013-05-14 16:05:51 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2013-05-14 16:05:51 -0700 |
| commit | b3946dc119cb89fe9f3cd55daa8d8c7a708274a8 (patch) | |
| tree | 390057fc055fe5a503bcb633a051a2e0a14c6fda /src/pkg/bytes/bytes.go | |
| parent | f1583bb9563827fe132c97798657a6c60e6a0457 (diff) | |
| download | go-b3946dc119cb89fe9f3cd55daa8d8c7a708274a8.tar.xz | |
runtime/bytes: fast Compare for byte arrays and strings.
Uses SSE instructions to process 16 bytes at a time.
fixes #5354
R=bradfitz, google
CC=golang-dev
https://golang.org/cl/8853048
Diffstat (limited to 'src/pkg/bytes/bytes.go')
| -rw-r--r-- | src/pkg/bytes/bytes.go | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go index e42f744394..b07902579c 100644 --- a/src/pkg/bytes/bytes.go +++ b/src/pkg/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 |
