From 08af216c75a583a198c4ccfe68628c74554ee82f Mon Sep 17 00:00:00 2001 From: apocelipes Date: Tue, 2 Apr 2024 13:41:00 +0000 Subject: encoding/json: use slices to simplify the code Use "slices.Equal" instead of "reflect.DeepEqual". Replace unnecessary helper type "byIndex" with "slices.SortFunc". No effect on benchmarks. Change-Id: I1fb2768ea6d9db7f487408fa109343be3f1741d5 GitHub-Last-Rev: 8429bc145272ae620fcd001b1de393bf3c0b6108 GitHub-Pull-Request: golang/go#66646 Reviewed-on: https://go-review.googlesource.com/c/go/+/575715 Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Carlos Amedee Reviewed-by: Ian Lance Taylor --- src/encoding/json/decode_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/encoding/json/decode_test.go') diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index a10c1e1ebb..f5b44677b3 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -14,6 +14,7 @@ import ( "math/big" "net" "reflect" + "slices" "strconv" "strings" "testing" @@ -1998,7 +1999,7 @@ func TestByteKind(t *testing.T) { if err != nil { t.Fatalf("Unmarshal error: %v", err) } - if !reflect.DeepEqual(got, want) { + if !slices.Equal(got, want) { t.Fatalf("Marshal/Unmarshal mismatch:\n\tgot: %v\n\twant: %v", got, want) } } @@ -2017,7 +2018,7 @@ func TestSliceOfCustomByte(t *testing.T) { if err != nil { t.Fatalf("Unmarshal error: %v", err) } - if !reflect.DeepEqual(got, want) { + if !slices.Equal(got, want) { t.Fatalf("Marshal/Unmarshal mismatch:\n\tgot: %v\n\twant: %v", got, want) } } -- cgit v1.3