mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
src: Use bytes.Equal instead of bytes.Compare where possible.
bytes.Equal is simpler to read and should also be faster because of short-circuiting and assembly implementations. Change generated automatically using: gofmt -r 'bytes.Compare(a, b) == 0 -> bytes.Equal(a, b)' gofmt -r 'bytes.Compare(a, b) != 0 -> !bytes.Equal(a, b)' R=golang-dev, dave, adg, rsc CC=golang-dev https://golang.org/cl/7038051
This commit is contained in:
parent
56961274bb
commit
46811d27ce
14 changed files with 25 additions and 25 deletions
|
|
@ -422,7 +422,7 @@ func TestUnmarshalMarshal(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Marshal: %v", err)
|
||||
}
|
||||
if bytes.Compare(jsonBig, b) != 0 {
|
||||
if !bytes.Equal(jsonBig, b) {
|
||||
t.Errorf("Marshal jsonBig")
|
||||
diff(t, b, jsonBig)
|
||||
return
|
||||
|
|
@ -474,7 +474,7 @@ func TestLargeByteSlice(t *testing.T) {
|
|||
if err := Unmarshal(b, &s1); err != nil {
|
||||
t.Fatalf("Unmarshal: %v", err)
|
||||
}
|
||||
if bytes.Compare(s0, s1) != 0 {
|
||||
if !bytes.Equal(s0, s1) {
|
||||
t.Errorf("Marshal large byte slice")
|
||||
diff(t, s0, s1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue