Commit Graph

3089 Commits

Author SHA1 Message Date
Joe Groff
5ed6bd831e KeyPaths: Dynamic appending between possibly-mismatched types.
Make the `appending` operation between `AnyKeyPath` and `PartialKeyPath` values work. Add a test checking the combinations.
2017-04-04 11:31:15 -07:00
Joe Groff
895ce94ae5 KeyPaths: implement "appending" 2017-04-04 11:31:15 -07:00
Joe Groff
04a6d23f7e KeyPaths: Equatable/Hashable implementation. 2017-04-04 11:31:15 -07:00
Joe Groff
cdbdb7a6e8 stdlib: Skeleton implementation of proposed KeyPath API.
Handles projection of stored struct and class properties. Most other functionality TODO.
2017-04-04 11:31:15 -07:00
Max Moiseev
10f0c9e89a Merge branch 'master' into new-integer-protocols 2017-04-03 11:49:56 -07:00
codestergit
aa9e9edc8a [Stdlib] Improves sort and sorted to accept throwing clousre
This commit resolves https://bugs.swift.org/browse/SR-715
2017-04-03 16:59:02 +05:30
practicalswift
ca72b12287 [gardening] Remove accidental \t:s 2017-04-02 16:03:54 +02:00
Nate Cook
e5eeb19726 [docs] Improve example hashValue implementation
The naive implementation in the original had even worse performance
than anticipated.
2017-04-01 15:07:04 -04:00
swift-ci
3c77cb7b07 Merge pull request #8379 from DougGregor/se-0160 2017-03-31 22:31:20 -07:00
Doug Gregor
cc225eb9fa [Stdlib] Silence all warnings about deprecated @objc inference.
This eliminates 26 Objective-C entry points that we never intended to expose, but that came “for free” with the @objc inference rules.
2017-03-31 21:53:55 -07:00
swift-ci
c8d2f179e7 Merge pull request #8464 from eeckstein/array-append-contentof 2017-03-31 17:59:36 -07:00
Philippe Hausler
ef7026a23e Merge pull request #8283 from phausler/characterset_perf
[Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
2017-03-31 15:49:32 -07:00
Erik Eckstein
9ce3df106e Add two new array semantics functions.
array.append_element(newElement: Element)
array.append_contentsOf(contentsOf newElements: S)

And allow early inlining of them.
Those functions will be needed to optimize Array.append(contentsOf)
2017-03-31 15:31:57 -07:00
Philippe Hausler
6c26b80e6e [Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
Some cases of using isSuperset can cause crashes, this was caused by improper subclassing callouts; this pr resolves those failures (and provides unit tests for that case)
The cases where the bridge was traversed too much now only causes a single bridge out call (without needing to reallocate or thrash retain/release)
String.components(separatedBy: CharacterSet) should be considerably faster now not only for more apporpriate bridging calls but also no longer needing to bridge arrays back and forth.

Resolves the following issues:
rdar://problem/17281998
rdar://problem/26611771
rdar://problem/29738989
2017-03-31 11:06:38 -07:00
Max Moiseev
3cbcd716f5 Merge branch 'master' into new-integer-protocols 2017-03-31 10:03:20 -07:00
Max Moiseev
b0c45481bf Adding an explicit type context for == 2017-03-30 12:30:03 -07:00
Max Moiseev
cd98994b9d Improving the performance of String.UTF8View 2017-03-30 10:22:30 -07:00
Philippe Hausler
bb674fe75a Merge pull request #6421 from phausler/dictionary_bridge_perf
Add a fast-path case for enumeration of keys and objects for bridged Dictionaries
2017-03-28 08:36:55 -07:00
Max Moiseev
2f5fd8e2ed Improving benchmarks 2017-03-27 14:59:27 -07:00
Max Moiseev
ec8e286b5c Merge branch 'master' into new-integer-protocols 2017-03-24 14:14:00 -07:00
Slava Pestov
2141c1515b stdlib: Remove obsolete FIXME: comment 2017-03-23 22:20:08 -07:00
Max Moiseev
2c9be47551 Merge branch 'master' into new-integer-protocols 2017-03-23 16:46:01 -07:00
Doug Gregor
2e283118e6 [Stdlib] Eliminate a warning about a redundant conformance 2017-03-22 17:35:15 -07:00
Doug Gregor
388f0c505e [Stdlib] Eliminate explicit constraints made redundant by inferred ones. 2017-03-22 17:35:12 -07:00
Max Moiseev
b9fb3badc8 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-03-22 12:30:24 -07:00
Dave Abrahams
1e8d069f75 [stdlib] SequenceWrapper: forward all requirements
One wants to take advantage of any optimization the Base Sequence may implement, especially because it will often be a Collection!
2017-03-18 13:20:03 -07:00
Dave Abrahams
365ef19cd4 [stdlib] SequenceWrapper: make it compile
Not sure why my local tests were compiling without this change, but clearly it is needed.
2017-03-18 12:28:55 -07:00
Dave Abrahams
7cfddace23 [stdlib] SequenceWrapper: ++principled simplicity
Not sure why the earlier version even compiled; the `Iterator.Element` types need to match up for most of these operations, and the `Iterator` types themselves need to match for some.
2017-03-18 12:05:54 -07:00
Dave Abrahams
639b04f7db [stdlib] _SequenceWrapper proposed simplification
I think the complexity of these condition extensions is unneeded, and may be vestigial from a time when the compiler was less cooperative.   Test this theory using CI
2017-03-18 11:47:32 -07:00
swift-ci
3e085fca4b Merge pull request #7946 from DougGregor/all-conformance-constraint-sources 2017-03-18 01:30:27 -07:00
Doug Gregor
13c4ae0168 [Standard library] Eliminate redundant conformance constraints.
Eliminate all of the redundant conformance constraints in the standard
library that were identified by the newly-introduced warning for
redundant, explicitly-specified conformances.
2017-03-17 20:15:09 -10:00
Roman Levenstein
2c811b82a1 Adjust some tests to pass in non-resilient and resilient modes. 2017-03-16 19:46:11 -07:00
Roman Levenstein
29ad714bb7 Annotate stdlib functions to get a good performance even in resilient mode, when -sil-serialize-all is disabled
This commit mostly improves the performance of arrays and ranges.
It does not cover Strings, Dictionaries and Sets yet.
2017-03-16 19:46:11 -07:00
Robert Widmann
81968e21ff Remove erroneous drop(while:) optimization
Calling drop(while: ) after prefix() on a pure Sequence loses the
prefix, because in the internal drop(while: ) override grabs the
underlying base iterator from _PrefixSequence and wraps it in a
_DropWhileSequence.
2017-03-15 17:01:13 -04:00
swift-ci
f89e3869f5 Merge pull request #8079 from samirGuerdah/fixTypo 2017-03-14 08:52:30 -07:00
samirMSTF
9d9cd82c59 Fix typo 2017-03-14 14:16:59 +01:00
Michael Gottesman
6d7b11c8eb [stdlib] Cleanup usage of Builtin.castToNativeObject(...).
Previously often times when casting a value, we would just pass along the
cleanup of the uncasted value. With semantic SIL this is no longer correct since
the cleanup now needs to be on the cast result.

This caused problems for certain usages of Builtin.castToNativeObject(...) by
the stdlib. Specifically, the stdlib was using this on AnyObject values that
were not necessarily native. Since we were recreating the cleanup on the native
value, a swift native release was being used =><=.

In this commit I solve this problem by:

1. Adding an assert in Builtin.castToNativeObject(...) that ensures that any value
passed to Builtin.castToNativeObject() is known conservatively to use swift
native reference counting.

2. I changed all uses where we do not have a precondition of a native ref
counting type to use Builtin.castToUnknownObject(...).

3. I added a new Builtin called Builtin.unsafeCastToNativeObject(...) that does
not have the compile time check. I used this to rewrite callsites in the stdlib
where we know via preconditions that an AnyObject will dynamically always be
native.

rdar://29791263
2017-03-14 00:10:16 -07:00
Max Moiseev
4f0c7a582c Fixing some more validation tests 2017-03-13 16:37:30 -07:00
Max Moiseev
daf088ddea Default implementation of instance bitWidth for FixedWidthInteger
Conforming types already provide the static bitWidth property. Instance
one can be implemented in a protocol extension.

Resolves: <rdar://problem/30186638>
2017-03-13 15:24:02 -07:00
Max Moiseev
233fb21dd6 multipliedFullWidth(by:) and dividingFullWidth(_:) 2017-03-13 15:16:58 -07:00
Max Moiseev
48b5899c0d WithOverflow => ReportingOverflow 2017-03-13 12:22:36 -07:00
Max Moiseev
ff81681f4f Properly naming bit count properties 2017-03-13 11:50:02 -07:00
Max Moiseev
7d73b2e1ca Arithmetic => Numeric 2017-03-13 11:50:02 -07:00
Max Moiseev
187aa923ff Fixing heterogeneous <, failable init from other ints, and init from floats 2017-03-10 17:09:15 -08:00
Joe Groff
eb40d4303b Sema: Add a stdlib-internal _openExistential helper.
Leverage the "special type-checking semantics" hack to pass an opened existential down to an arbitrary subexpression. Please don't use this.
2017-03-10 13:41:00 -08:00
Joe Groff
294913e114 Fix _stdlib_getErrorDefaultUserInfo to have the signature the runtime expects.
The ABI mismatch here would cause a crash in cases when the Foundation overlay wasn't available, or its implementation of swift_Foundation_getErrorDefaultUserInfo wasn't dynamically resolvable, such as in a stripped statically linked binary. Fixes rdar://problem/29173132.
2017-03-08 14:56:02 -08:00
Max Moiseev
f4c7e0464b Merge remote-tracking branch 'origin/new-integer-protocols' into new-integer-protocols 2017-03-07 16:42:07 -08:00
Max Moiseev
835b8809d2 Merge branch 'master' into new-integer-protocols 2017-03-07 16:18:54 -08:00
Maxim Moiseev
98e6cafdc8 [stdlib] Adding a deprecated version of flatMap to warn misuses. (#7823)
Due to implicit promotion to optional it is possible to call flatMap
with a closure, that does not return an optional. This way the code
works, but is unnecessary inefficient. Such uses of flatMap can and
should be replaced with map.
2017-03-06 10:16:42 -08:00
Dave Abrahams
7af65d9e09 Merge pull request #7870 from stephentyrone/FloatingPoint-Hashable
FloatingPoint should imply Hashable. 

 `Hashable` is related to `Equatable`, and `FloatingPoint` is `Equatable`, with enough additional constraints that `Hashable` conformance is practical.  

There's *almost* no excuse for any `Equatable` thing not to also be `Hashable`; the exception is when the underlying representation may be denormalized in some way that makes it impossible or expensive to normalize (e.g. `Set`).  Floating point numbers have denormalized forms, so this comes down to the cost of normalization.  Since we can't imagine a representation whose normalization is much more expensive than the subsequent hashing step, the conformance belongs.
2017-03-05 08:12:29 -08:00