summaryrefslogtreecommitdiffstats
path: root/vendor/google.golang.org/protobuf/proto/equal.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/protobuf/proto/equal.go')
-rw-r--r--vendor/google.golang.org/protobuf/proto/equal.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/vendor/google.golang.org/protobuf/proto/equal.go b/vendor/google.golang.org/protobuf/proto/equal.go
index 10902bd8..4dba2b96 100644
--- a/vendor/google.golang.org/protobuf/proto/equal.go
+++ b/vendor/google.golang.org/protobuf/proto/equal.go
@@ -111,18 +111,31 @@ func equalList(fd pref.FieldDescriptor, x, y pref.List) bool {
// equalValue compares two singular values.
func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
- switch {
- case fd.Message() != nil:
- return equalMessage(x.Message(), y.Message())
- case fd.Kind() == pref.BytesKind:
- return bytes.Equal(x.Bytes(), y.Bytes())
- case fd.Kind() == pref.FloatKind, fd.Kind() == pref.DoubleKind:
+ switch fd.Kind() {
+ case pref.BoolKind:
+ return x.Bool() == y.Bool()
+ case pref.EnumKind:
+ return x.Enum() == y.Enum()
+ case pref.Int32Kind, pref.Sint32Kind,
+ pref.Int64Kind, pref.Sint64Kind,
+ pref.Sfixed32Kind, pref.Sfixed64Kind:
+ return x.Int() == y.Int()
+ case pref.Uint32Kind, pref.Uint64Kind,
+ pref.Fixed32Kind, pref.Fixed64Kind:
+ return x.Uint() == y.Uint()
+ case pref.FloatKind, pref.DoubleKind:
fx := x.Float()
fy := y.Float()
if math.IsNaN(fx) || math.IsNaN(fy) {
return math.IsNaN(fx) && math.IsNaN(fy)
}
return fx == fy
+ case pref.StringKind:
+ return x.String() == y.String()
+ case pref.BytesKind:
+ return bytes.Equal(x.Bytes(), y.Bytes())
+ case pref.MessageKind, pref.GroupKind:
+ return equalMessage(x.Message(), y.Message())
default:
return x.Interface() == y.Interface()
}