Skip to content

Commit cc13161

Browse files
apocelipesgopherbot
authored andcommitted
encoding/xml: use reflect.Value.IsZero
IsZero does the same thing, using this rather than writing it again. Change-Id: I62810ac2d1a6e189feac03b022c8931fb6993e19 GitHub-Last-Rev: 1d5fd10 GitHub-Pull-Request: #63519 Reviewed-on: https://go-review.googlesource.com/c/go/+/534935 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 15a274b commit cc13161

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/encoding/xml/marshal.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,16 +1120,12 @@ func isEmptyValue(v reflect.Value) bool {
11201120
switch v.Kind() {
11211121
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
11221122
return v.Len() == 0
1123-
case reflect.Bool:
1124-
return !v.Bool()
1125-
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
1126-
return v.Int() == 0
1127-
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
1128-
return v.Uint() == 0
1129-
case reflect.Float32, reflect.Float64:
1130-
return v.Float() == 0
1131-
case reflect.Interface, reflect.Pointer:
1132-
return v.IsNil()
1123+
case reflect.Bool,
1124+
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
1125+
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,
1126+
reflect.Float32, reflect.Float64,
1127+
reflect.Interface, reflect.Pointer:
1128+
return v.IsZero()
11331129
}
11341130
return false
11351131
}

0 commit comments

Comments
 (0)