stdlib: make CollectionType._prext_isEmpty dynamically dispatched

This change makes isEmpty faster for Dictionary and Set, when invoked
from generic algorithms.

Swift SVN r27736
This commit is contained in:
Dmitri Hrybenko
2015-04-26 00:08:14 +00:00
parent 80dc495ad0
commit f6090c1c89
6 changed files with 295 additions and 22 deletions

View File

@@ -18,18 +18,6 @@ GElement = "Generator.Element"
}%
//===----------------------------------------------------------------------===//
// isEmpty
//===----------------------------------------------------------------------===//
extension CollectionType {
/// Returns `true` iff `self` is empty.
final public var _prext_isEmpty: Bool {
// FIXME: dynamic dispatch for Set and Dictionary.
return startIndex == endIndex
}
}
//===----------------------------------------------------------------------===//
// first
//===----------------------------------------------------------------------===//