mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
stdlib: add an extension point for SequenceType.contains()
This makes the protocol extension as fast as static dispatch for Set.contains(). Swift SVN r27396
This commit is contained in:
@@ -261,7 +261,10 @@ extension SequenceType ${"" if preds else "where Self.Generator.Element : Compar
|
||||
extension SequenceType where Self.Generator.Element : Equatable {
|
||||
/// Return `true` iff `x` is in `self`.
|
||||
final public func _prext_contains(element: ${GElement}) -> Bool {
|
||||
// FIXME: dynamic dispatch for Set and Dictionary.
|
||||
if let result? = _customContainsEquatableElement(element) {
|
||||
return result
|
||||
}
|
||||
|
||||
for e in self {
|
||||
if e == element {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user