Commit Graph

8 Commits

Author SHA1 Message Date
Dmitri Hrybenko
2bccb13463 stdlib: add an extension point for SequenceType.contains()
This makes the protocol extension as fast as static dispatch for
Set.contains().

Swift SVN r27396
2015-04-17 02:09:59 +00:00
Dmitri Hrybenko
0d6374bb58 stdlib/HashedCollections: skip computing the hash for lookups in empty
collections

Swift SVN r27395
2015-04-17 01:56:19 +00:00
Dmitri Hrybenko
8628a3d4e8 stdlib: _copyToNativeArrayBuffer(): use unsafe more
Now we initialize the array buffer from sequences using unsafe pointer
arithmetic, which avoids extra retain/release traffic.  But since the
size of the sequence is not known in advance, we only initialize as much
as underestimateCount() promises, and fall back to the slow approach for
the tail.  Nevertheless, for collections, where the size is known
precisely, this technique is suboptimal only by one branch.

rdar://20530390

Swift SVN r27380
2015-04-16 20:49:22 +00:00
Dmitri Hrybenko
c48d6aa0ab stdlib: change underestimateCount() into a method
rdar://19895265

Swift SVN r27346
2015-04-16 05:05:17 +00:00
Dmitri Hrybenko
c7c25ad298 tests: fix a warning about declaring a public method for an internal type
Swift SVN r27345
2015-04-16 05:05:12 +00:00
Dmitri Hrybenko
581e853428 stdlib: make filter() a protocol requirement for range replaceable collections
This allows array types to get the best performance.  The default
implementation for range replaceable collections appends elements one by
one, and the optimizer can't hoist uniqueness checks from the loop in
that case yet.

Swift SVN r27314
2015-04-15 05:17:28 +00:00
Dmitri Hrybenko
0af19e7ff3 stdlib: use unsafeBitCast to implement map() and filter() on top of lazy()
Array(other_collection) is using an optimized code path for copying
collections.  An explicit for loop does not.

This commit should recover the performance regression in
rdar://20530390.

Swift SVN r27313
2015-04-15 05:17:27 +00:00
Dmitri Hrybenko
d267b86cb6 stdlib: move the bulk of SequenceType algorithms to protocol extensions
rdar://19895265

Swift SVN r27269
2015-04-14 01:53:19 +00:00