Commit Graph

24 Commits

Author SHA1 Message Date
Dmitri Hrybenko
fd14e70e48 stdlib: rename find() to indexOf() per API review
Swift SVN r27849
2015-04-28 00:30:37 +00:00
Dmitri Hrybenko
f6090c1c89 stdlib: make CollectionType._prext_isEmpty dynamically dispatched
This change makes isEmpty faster for Dictionary and Set, when invoked
from generic algorithms.

Swift SVN r27736
2015-04-26 00:08:14 +00:00
Doug Gregor
793b3326af Implement the new rules for argument label defaults.
The rule changes are as follows:
  * All functions (introduced with the 'func' keyword) have argument
  labels for arguments beyond the first, by default. Methods are no
  longer special in this regard.
  * The presence of a default argument no longer implies an argument
  label.

The actual changes to the parser and printer are fairly simple; the
rest of the noise is updating the standard library, overlays, tests,
etc.

With the standard library, this change is intended to be API neutral:
I've added/removed #'s and _'s as appropriate to keep the user
interface the same. If we want to separately consider using argument
labels for more free functions now that the defaults in the language
have shifted, we can tackle that separately.

Fixes rdar://problem/17218256.

Swift SVN r27704
2015-04-24 19:03:30 +00:00
Dmitri Hrybenko
7afe30ec7d stdlib: make all collections sliceable, first steps
This commit adds a minimally working Slice type and minimal tests.  Even
though it might seem logical how the new protocol requirements are
injected in the CollectionType hierarchy, it is very fragile and
required many attempts to get the typechecker to finally accept it.
Because I want to ensure that the type checker does not regress, I'm
commiting a patch that does not do much yet.

Swift SVN r27665
2015-04-24 01:27:15 +00:00
Dmitri Hrybenko
af38ea1381 stdlib: add MutableCollectionType._prext_partition()
Swift SVN r27643
2015-04-23 20:52:00 +00:00
Dmitri Hrybenko
005c76ba07 Revert "stdlib: make all collections sliceable, first steps"
This reverts commit r27617.  Too late, it crashes the type checker now.

Swift SVN r27618
2015-04-23 00:56:30 +00:00
Dmitri Hrybenko
0cdf289c9c stdlib: make all collections sliceable, first steps
This commit adds a minimally working Slice type and minimal tests.  Even
though it might seem logical how the new protocol requirements are
injected in the CollectionType hierarchy, it is very fragile and
required many attempts to get the typechecker to finally accept it.
Because I want to ensure that the type checker does not regress, I'm
commiting a patch that does not do much yet.

Swift SVN r27617
2015-04-23 00:26:08 +00:00
Dmitri Hrybenko
730e6afee0 Revert "stdlib: make map() dynamically dispatched"
This reverts commit r27607.  It broke parse_stdlib_* tests.

Swift SVN r27609
2015-04-22 22:30:45 +00:00
Dmitri Hrybenko
21e5a83631 stdlib: make map() dynamically dispatched
This change tries to recover the performance regression in map() that
was caused by moving map() to a protocol extension and degrading the
static type information (when mapping a collection, we only know that it
is a sequence).  Adding map() to the witness table allows us to provide
a specialized implementation for collections, and hopefully recover the
lost performance.

This is a speculative change, I don't have performance numbers.  I will
watch the performance buildbots and if this change does not help, I'll
revert.

Swift SVN r27607
2015-04-22 22:08:16 +00:00
Dmitri Hrybenko
d9848a6c41 stdlib: migrate last() to use a protocol extension
Swift SVN r27602
2015-04-22 20:42:04 +00:00
Dmitri Hrybenko
883ac4c11f stdlib: implement a defaulted CollectionType._prext_count() method
Swift SVN r27447
2015-04-18 04:25:15 +00:00
Dmitri Hrybenko
3a1410fdec stdlib: add a default implementation for CollectionType.generate()
Swift SVN r27442
2015-04-17 21:55:09 +00:00
Dmitri Hrybenko
02d254047b 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
2015-04-17 05:03:28 +00:00
Dmitri Hrybenko
e94b0f9b40 Revert "stdlib: add a hook for dynamic dispatch in CollectionType.find()"
This reverts commit r27402.  It broke tests.

Swift SVN r27403
2015-04-17 04:59:29 +00:00
Dmitri Hrybenko
fe53f87dfc stdlib: add a hook for dynamic dispatch in CollectionType.find()
This allows Set.find() to be equally efficient in static and generic
contexts.

Swift SVN r27402
2015-04-17 04:19:49 +00:00
Dmitri Hrybenko
1368a908dc tests: better tests for SequenceType._prext_contains()
Swift SVN r27399
2015-04-17 04:06:45 +00:00
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