Skip to content

Commit

Permalink
struct cleanup indentation in RequestedDevice Equals
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin committed Apr 11, 2019
1 parent 0767a46 commit f474641
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f474641

Please sign in to comment.