From: tengufromsky Date: Thu, 19 Apr 2018 18:56:45 +0000 (+0300) Subject: encoding/json: remove unnecessary if conditions X-Git-Tag: go1.11beta1~749 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c2a53b1b82161aaff2f2e09a46cbee8eccea8cd8;p=gostls13.git encoding/json: remove unnecessary if conditions Fixes gosimple warning "if err != nil { return err }; return nil' can be simplified to 'return err" Change-Id: Ife7f78a3a76ab7802b5561d1afec536e103b504a Reviewed-on: https://go-review.googlesource.com/108275 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go index 9479e1a5c6..6a66940034 100644 --- a/src/encoding/json/decode.go +++ b/src/encoding/json/decode.go @@ -868,11 +868,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool isNull := item[0] == 'n' // null u, ut, pv := indirect(v, isNull) if u != nil { - err := u.UnmarshalJSON(item) - if err != nil { - return err - } - return nil + return u.UnmarshalJSON(item) } if ut != nil { if item[0] != '"' { @@ -899,11 +895,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool } return errPhase } - err := ut.UnmarshalText(s) - if err != nil { - return err - } - return nil + return ut.UnmarshalText(s) } v = pv