1
0
mirror of https://github.com/golang/go synced 2024-11-23 14:30:02 -07:00

encoding/xml: use reflect.Value.IsZero

IsZero does the same thing, using this rather than writing it again.

Change-Id: I62810ac2d1a6e189feac03b022c8931fb6993e19
GitHub-Last-Rev: 1d5fd10d96
GitHub-Pull-Request: golang/go#63519
Reviewed-on: https://go-review.googlesource.com/c/go/+/534935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
apocelipes 2023-10-12 15:55:54 +00:00 committed by Gopher Robot
parent 15a274b621
commit cc13161a0d

View File

@ -1120,16 +1120,12 @@ func isEmptyValue(v reflect.Value) bool {
switch v.Kind() {
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
return v.Len() == 0
case reflect.Bool:
return !v.Bool()
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int() == 0
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return v.Uint() == 0
case reflect.Float32, reflect.Float64:
return v.Float() == 0
case reflect.Interface, reflect.Pointer:
return v.IsNil()
case reflect.Bool,
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,
reflect.Float32, reflect.Float64,
reflect.Interface, reflect.Pointer:
return v.IsZero()
}
return false
}