Skip to content

Commit c824e5a

Browse files
committed
encoding/json: make use of reflect.Type.{OverflowInt, OverflowUint}
CL 567296 adds {OverflowComplex, OverflowFloat, OverflowInt, OverflowUint} to reflect.Type, this CL uses these methods to simplify code.
1 parent 33013e8 commit c824e5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/encoding/json/decode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ func (d *decodeState) object(v reflect.Value) error {
776776
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
777777
s := string(key)
778778
n, err := strconv.ParseInt(s, 10, 64)
779-
if err != nil || reflect.Zero(kt).OverflowInt(n) {
779+
if err != nil || kt.OverflowInt(n) {
780780
d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
781781
break
782782
}
@@ -785,7 +785,7 @@ func (d *decodeState) object(v reflect.Value) error {
785785
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
786786
s := string(key)
787787
n, err := strconv.ParseUint(s, 10, 64)
788-
if err != nil || reflect.Zero(kt).OverflowUint(n) {
788+
if err != nil || kt.OverflowUint(n) {
789789
d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
790790
break
791791
}

0 commit comments

Comments
 (0)