From f4746411cab328215def6508955b160a53452da3 Mon Sep 17 00:00:00 2001 From: Lang Martin Date: Thu, 28 Mar 2019 16:22:48 -0400 Subject: [PATCH] struct cleanup indentation in RequestedDevice Equals --- nomad/structs/structs.go | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 58afc10c675..11fd1a0f2d0 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2134,31 +2134,36 @@ type RequestedDevice struct { } func (r *RequestedDevice) Equals(o *RequestedDevice) bool { - if r.Name == o.Name && - r.Count == o.Count { + if r == o { + return true + } + if r == nil || o == nil { + return false + } + if !(r.Name == o.Name && r.Count == o.Count) { + return false + } - // r.Constraints == o.Constraints, order sensitive - if len(r.Constraints) != len(o.Constraints) { + // r.Constraints == o.Constraints, order sensitive + if len(r.Constraints) != len(o.Constraints) { + return false + } + for i, c := range r.Constraints { + if !c.Equal(o.Constraints[i]) { return false } - for i, c := range r.Constraints { - if !c.Equal(o.Constraints[i]) { - return false - } - } + } - // r.Affinities == o.Affinities, order sensitive - if len(r.Affinities) != len(o.Affinities) { + // r.Affinities == o.Affinities, order sensitive + if len(r.Affinities) != len(o.Affinities) { + return false + } + for i, a := range r.Affinities { + if !a.Equal(o.Affinities[i]) { return false } - for i, a := range r.Affinities { - if !a.Equal(o.Affinities[i]) { - return false - } - } - return true } - return false + return true } func (r *RequestedDevice) Copy() *RequestedDevice {