mirror of
https://github.com/golang/go
synced 2024-11-16 21:14:44 -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:
parent
15a274b621
commit
cc13161a0d
@ -1120,16 +1120,12 @@ func isEmptyValue(v reflect.Value) bool {
|
|||||||
switch v.Kind() {
|
switch v.Kind() {
|
||||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||||
return v.Len() == 0
|
return v.Len() == 0
|
||||||
case reflect.Bool:
|
case reflect.Bool,
|
||||||
return !v.Bool()
|
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,
|
||||||
return v.Int() == 0
|
reflect.Float32, reflect.Float64,
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
reflect.Interface, reflect.Pointer:
|
||||||
return v.Uint() == 0
|
return v.IsZero()
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
return v.Float() == 0
|
|
||||||
case reflect.Interface, reflect.Pointer:
|
|
||||||
return v.IsNil()
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user