@@ -2177,61 +2177,56 @@ extension _ArrayBufferProtocol {
2177
2177
}
2178
2178
2179
2179
% for (Self, a_Self) in arrayTypes:
2180
- // NOTE: The '==' and '!=' below only handles array types
2181
- // that are the same, e.g. Array<Int> and Array<Int>, not
2182
- // ArraySlice<Int> and Array<Int>.
2183
2180
2184
- /// Returns `true` if these arrays contain the same elements.
2185
- @_inlineable
2186
- public func == < Element : Equatable > (
2187
- lhs: ${ Self} < Element> , rhs: ${ Self} < Element>
2188
- ) -> Bool {
2189
- let lhsCount = lhs. count
2190
- if lhsCount != rhs. count {
2191
- return false
2192
- }
2181
+ extension ${ Self} where Element : Equatable {
2182
+ /// Returns `true` if these arrays contain the same elements.
2183
+ @_inlineable
2184
+ public static func == ( lhs: ${ Self} < Element> , rhs: ${ Self} < Element> ) -> Bool {
2185
+ let lhsCount = lhs. count
2186
+ if lhsCount != rhs. count {
2187
+ return false
2188
+ }
2193
2189
2194
- // Test referential equality.
2195
- if lhsCount == 0 || lhs. _buffer. identity == rhs . _buffer . identity {
2196
- return true
2197
- }
2190
+ // Test referential equality.
2191
+ if lhsCount == 0 || lhs. _buffer. identity == rhs . _buffer . identity {
2192
+ return true
2193
+ }
2198
2194
2199
- % if Self == 'ArraySlice':
2195
+ % if Self == 'ArraySlice':
2200
2196
2201
- var streamLHS = lhs. makeIterator ( )
2202
- var streamRHS = rhs. makeIterator ( )
2197
+ var streamLHS = lhs. makeIterator ( )
2198
+ var streamRHS = rhs. makeIterator ( )
2203
2199
2204
- var nextLHS = streamLHS. next ( )
2205
- while nextLHS != nil {
2206
- let nextRHS = streamRHS. next ( )
2207
- if nextLHS != nextRHS {
2208
- return false
2200
+ var nextLHS = streamLHS. next ( )
2201
+ while nextLHS != nil {
2202
+ let nextRHS = streamRHS. next ( )
2203
+ if nextLHS != nextRHS {
2204
+ return false
2205
+ }
2206
+ nextLHS = streamLHS. next ( )
2209
2207
}
2210
- nextLHS = streamLHS. next ( )
2211
- }
2212
2208
2213
- % else:
2209
+ % else:
2214
2210
2215
- _sanityCheck( lhs. startIndex == 0 && rhs. startIndex == 0 )
2216
- _sanityCheck( lhs. endIndex == lhsCount && rhs. endIndex == lhsCount)
2211
+ _sanityCheck( lhs. startIndex == 0 && rhs. startIndex == 0 )
2212
+ _sanityCheck( lhs. endIndex == lhsCount && rhs. endIndex == lhsCount)
2217
2213
2218
- // We know that lhs.count == rhs.count, compare element wise.
2219
- for idx in 0 ..< lhsCount {
2220
- if lhs [ idx] != rhs [ idx] {
2221
- return false
2214
+ // We know that lhs.count == rhs.count, compare element wise.
2215
+ for idx in 0 ..< lhsCount {
2216
+ if lhs [ idx] != rhs [ idx] {
2217
+ return false
2218
+ }
2222
2219
}
2223
- }
2224
- % end
2220
+ % end
2225
2221
2226
- return true
2227
- }
2222
+ return true
2223
+ }
2228
2224
2229
- /// Returns `true` if the arrays do not contain the same elements.
2230
- @_inlineable
2231
- public func != < Element : Equatable> (
2232
- lhs: ${ Self} < Element> , rhs: ${ Self} < Element>
2233
- ) - > Bool {
2234
- return !( lhs == rhs)
2225
+ /// Returns `true` if the arrays do not contain the same elements.
2226
+ @_inlineable
2227
+ public static func != ( lhs: ${ Self} < Element> , rhs: ${ Self} < Element> ) - > Bool {
2228
+ return !( lhs == rhs)
2229
+ }
2235
2230
}
2236
2231
2237
2232
extension ${ Self} {
0 commit comments