@@ -80,8 +80,8 @@ func subsetOfGroups(inner, outer map[string]*cb.ConfigGroup) bool {
80
80
return true
81
81
}
82
82
83
- // If inner is not the empty set, then the outer empty set cannot be a superset of inner
84
- if len (outer ) == 0 {
83
+ // If inner has more elements than outer, it cannot be a subset
84
+ if len (inner ) > len ( outer ) {
85
85
return false
86
86
}
87
87
@@ -101,8 +101,8 @@ func subsetOfPolicies(inner, outer map[string]*cb.ConfigPolicy) bool {
101
101
return true
102
102
}
103
103
104
- // If inner is not the empty set, then the outer empty set cannot be a superset of inner
105
- if len (outer ) == 0 {
104
+ // If inner has more elements than outer, it cannot be a subset
105
+ if len (inner ) > len ( outer ) {
106
106
return false
107
107
}
108
108
@@ -122,8 +122,8 @@ func subsetOfValues(inner, outer map[string]*cb.ConfigValue) bool {
122
122
return true
123
123
}
124
124
125
- // If inner is not the empty set, then the outer empty set cannot be a superset of inner
126
- if len (outer ) == 0 {
125
+ // If inner has more elements than outer, it cannot be a subset
126
+ if len (inner ) > len ( outer ) {
127
127
return false
128
128
}
129
129
@@ -143,27 +143,12 @@ func equalConfigGroup(lhs, rhs *cb.ConfigGroup) bool {
143
143
return false
144
144
}
145
145
146
- if ! subsetOfGroups (lhs .Groups , rhs .Groups ) {
147
- return false
148
- }
149
-
150
- if ! subsetOfGroups (rhs .Groups , lhs .Groups ) {
151
- return false
152
- }
153
-
154
- if ! subsetOfPolicies (lhs .Policies , rhs .Policies ) {
155
- return false
156
- }
157
-
158
- if ! subsetOfPolicies (rhs .Policies , lhs .Policies ) {
159
- return false
160
- }
161
-
162
- if ! subsetOfValues (lhs .Values , rhs .Values ) {
163
- return false
164
- }
165
-
166
- if ! subsetOfValues (rhs .Values , lhs .Values ) {
146
+ if ! subsetOfGroups (lhs .Groups , rhs .Groups ) ||
147
+ ! subsetOfGroups (rhs .Groups , lhs .Groups ) ||
148
+ ! subsetOfPolicies (lhs .Policies , rhs .Policies ) ||
149
+ ! subsetOfPolicies (rhs .Policies , lhs .Policies ) ||
150
+ ! subsetOfValues (lhs .Values , rhs .Values ) ||
151
+ ! subsetOfValues (rhs .Values , lhs .Values ) {
167
152
return false
168
153
}
169
154
0 commit comments