mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: document Compare/Equal semantics for nil arguments, and add tests.
R=golang-dev, bradfitz, r, r CC=golang-dev https://golang.org/cl/5676090
This commit is contained in:
parent
f18b0b0c16
commit
85f2d18a72
2 changed files with 26 additions and 17 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
// Compare returns an integer comparing the two byte arrays 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) {
|
||||
|
|
@ -37,6 +38,7 @@ func Compare(a, b []byte) int {
|
|||
}
|
||||
|
||||
// Equal returns a boolean reporting whether a == b.
|
||||
// A nil argument is equivalent to an empty slice.
|
||||
func Equal(a, b []byte) bool
|
||||
|
||||
func equalPortable(a, b []byte) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue