mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: add a hook for dynamic dispatch in CollectionType.find()
This hook allows Set.find() to be equally efficient in static and generic contexts. This time, with correct tests. Swift SVN r27404
This commit is contained in:
@@ -49,9 +49,11 @@ extension CollectionType where Self.${GElement} : Equatable {
|
||||
///
|
||||
/// Complexity: O(\ `self.count()`\ )
|
||||
final public func _prext_find(element: ${GElement}) -> Index? {
|
||||
// FIXME: dynamic dispatch for Set and Dictionary.
|
||||
// FIXME: _prext_indices
|
||||
for i in indices(self) {
|
||||
if let result? = _customFindEquatableElement(element) {
|
||||
return result
|
||||
}
|
||||
|
||||
for i in self._prext_indices {
|
||||
if self[i] == element {
|
||||
return i
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user