Commit Graph

3089 Commits

Author SHA1 Message Date
Michael Ilseman
4a17449d02 [stdlib] Shims for UBreakIterator and thread local storage.
Introduce shims for using UBreakIterators from ICU. Also introduce
shims for using thread local storage via pthreads.

We will be relying on ICU and UBreakIterators for grapheme
breaking. But, UBreakIterators are very expensive to create,
especially for the way we do grapheme breaking, which is relatively
stateless. Thus, we will stash one or more into thread local storage
and reset it as needed.

Note: Currently, pthread_key_t is hard coded for a single platform
(Darwin), but I have a static_assert alongside directions on how to
adapt it to any future platforms who differ in key type.
2017-05-10 15:21:07 -07:00
Nate Cook
f030652cc9 Merge pull request #9462 from natecook1000/nc-dict-keys-compat
[stdlib] Provide Swift 3 compatible Dict.keys/values
2017-05-10 15:37:39 -05:00
Nate Cook
822fec7b2b [stdlib] Make new Dict filter closure type match sequence 2017-05-10 11:24:37 -05:00
Nate Cook
44b12db536 [stdlib] Maintain old keys and values types in Swift 3 mode 2017-05-10 10:45:05 -05:00
swift-ci
d2c8d9c58b Merge pull request #9423 from apple/direct-transcoding 2017-05-09 21:27:10 -07:00
Dave Abrahams
c616b180ce [stdlib] Revise comments per proposed revisions to SE-0163 2017-05-09 18:37:20 -07:00
practicalswift
8c40c65c80 [gardening] Fix typos. 2017-05-09 21:50:04 +02:00
Dave Abrahams
c64534a873 [stdlib] API adjustments in preparation for proposal update 2017-05-09 11:19:24 -07:00
Dave Abrahams
e7b32f9dc9 [stdlib] UnicodeEncoding: hide/internalize APIs we're not sure about
The best high-level APIs for decoding/transcoding are still under active
investigation.  It's likely we want more views.  Therefore, leave
de-underscored/public only the lowest-level APIs for now.
2017-05-09 10:20:29 -07:00
swift-ci
e04e7cea9c Merge pull request #9412 from apple/direct-transcoding 2017-05-09 07:43:13 -07:00
Dave Abrahams
fd8cfea3ac [stdlib] String initialization with encoding and CString interop 2017-05-08 19:50:38 -07:00
swift-ci
40c05b3624 Merge pull request #9378 from airspeedswift/lazy-constraints 2017-05-08 18:21:09 -07:00
Max Moiseev
e6b0e3c7fb [stdlib] Removing the deprecated flatMap overload
The following code behaves incorrectly due to the presence of this
overload.

let a: Int = 1
let b: Int? = 2
let c: Int? = nil
let result: [Any] = [a, b, c].flatMap { $0 }

Fixes: <rdar://problem/31910642>
2017-05-08 11:26:31 -07:00
Dave Abrahams
cb5b5bad7c [stdlib] Clean up anti-idiomatic generic 2017-05-08 07:59:16 -07:00
Dave Abrahams
38b902d461 [stdlib] add Unsafe[Mutable]Pointer._max, unbounded buffer pointers 2017-05-08 07:58:18 -07:00
Dave Abrahams
9363b482db [stdlib] add _SentinelCollection/_SentinelIterator 2017-05-08 07:57:42 -07:00
ben-cohen
b6250eee15 fix indentation error 2017-05-08 07:47:47 -07:00
Dave Abrahams
c5d6880053 [stdlib] Add ASCII UnicodeEncoding, drop uses of legacy codecs
Preparation for new C-string interop.
2017-05-07 20:43:44 -07:00
Dave Abrahams
ca576bb9bc [stdlib] Add unconditional encode/transcode 2017-05-07 20:43:44 -07:00
Dave Abrahams
f4610e1638 [stdlib] encode/transcode => [encode/transcode]IfRepresentable...
...to make room for a more useful encode/transcode that inject replacement
characters when encoding fails.
2017-05-07 20:43:44 -07:00
ben-cohen
e4af80d39c Remove redudant constraints to supress warnings 2017-05-07 11:30:01 -07:00
ben-cohen
faba513f9e Constrain Lazy.Elements.Element == Element 2017-05-07 10:18:58 -07:00
Ben Cohen
f6f3ed0fe7 Add Collection constraints via protocol where clauses (#9374) 2017-05-07 08:55:48 -07:00
Dave Abrahams
8d888b5403 Merge pull request #9375 from apple/direct-transcoding
Direct transcoding
2017-05-07 06:39:18 -07:00
Dave Abrahams
776e0a632a [stdlib] Make a generic more idiomatic
NFC
2017-05-06 19:29:29 -07:00
Dave Abrahams
fc35acaac7 [stdlib] Every UnicodeCodec is a UnicodeEncoding 2017-05-06 19:26:58 -07:00
swift-ci
79258866a2 Merge pull request #9354 from apple/failable-unicode-encoding 2017-05-06 17:31:14 -07:00
Dave Abrahams
e08fd9af46 [stdlib] Direct unicode transcoding
without passing through decoded UnicodeScalars.
2017-05-06 16:58:08 -07:00
Dave Abrahams
796d004fd0 [stdlib] Allow Unicode Encoding to fail
This is needed for encodings such as Latin-1
2017-05-06 16:53:35 -07:00
swift-ci
4b69240301 Merge pull request #9372 from airspeedswift/drop-nuffing 2017-05-06 14:11:13 -07:00
ben-cohen
02562c3eb0 Substring.index(_:offsetBy:) is allowed offset of 0 2017-05-06 13:34:27 -07:00
Max Moiseev
178b9f0b44 [stdlib] Adding bounds check in a.subscript(Index) fast path
UnsafeBufferPoiunter subscript used in the fast path only checks bounds
in Debug mode, therefore extra checks are needed.

Addresses: <rdar://problem/31992473>
2017-05-05 15:26:24 -07:00
Dave Abrahams
5f21813ea1 Merge pull request #9340 from apple/integrate-utf32
[stdlib] Implement New UTF32 transcoding
2017-05-05 15:08:49 -07:00
Max Moiseev
2d49d17a75 [stdlib] Addressing the benchmark regression 2017-05-05 10:51:32 -07:00
Max Moiseev
47875fc4e0 [stdlib] Removing a few harmful overloads of <
At some point during the implementation of integer protocols these
overloads were necessary to make expressions like `i32 < 0` be faster
and unambiguous.
Now they are no longer necessary, and also cause problems for
expressions like `(u64 - u64) < u64`, where they cause the deprecated
`func - (Strideable, Strideable) -> Stride` be used, which is wrong, as
it will trap in many cases, where `func - (UInt64, UInt64) -> UInt64`
would not.

Fixes: <rdar://problem/31909031>
2017-05-05 10:51:32 -07:00
Dave Abrahams
dfd9eb34cf [stdlib] Implement New UTF32 transcoding 2017-05-05 09:53:44 -07:00
swift-ci
6f511d66fb Merge pull request #9301 from eeckstein/fix-resilience-build 2017-05-04 18:11:24 -07:00
Erik Eckstein
a5ddde2d45 stdlib: make a few structs @_fixed_layout to fix the resilience build.
This is a follow-up fix for making struct constructors inline(__always) in
155db0a4bd: Let Character literals, which fit into 64 bits, be folded into a single integer constant.
and
d8f1caf4a6: Inline all the new low-level bits

If we decide that this structs should not have fixed layout we must re-evaluate the performance difference of not being able to inline
the struct constructors.
2017-05-04 16:08:08 -07:00
swift-ci
144dc55dca Merge pull request #9297 from apple/integrate-utf16 2017-05-04 15:49:37 -07:00
Dave Abrahams
bea71aa80e [stdlib] Legacy UTF16 decoding in terms of new components 2017-05-04 11:03:46 -07:00
Michael Ilseman
47d0247476 [stdlib] Speed up Character construction from CharacterView.subscript (#9252)
This adds a fast path for single-code-unit Character
construction. Rather than use the general purpose String based
initializer (which then repeats grapheme breaking to ensure a trap,
amongst other inefficiencies), just make the Character from the single
unicode scalar value directly.

This also speeds up simple iteration of BMP strings when the optimizer
is unable to eliminate the subscript. Around 2x for ASCII, and around
20% for BMP UTF16.
2017-05-04 06:59:30 -07:00
Doug Gregor
f5c9ee346f Merge pull request #9158 from natecook1000/nc-devert-dictionary
[stdlib] Dictionary/Set enhancements (redux)
2017-05-03 14:07:27 -07:00
swift-ci
edd13eca60 Merge pull request #9188 from apple/new-unicode-decoders 2017-05-03 11:38:25 -07:00
Itai Ferber
9e12b95862 Merge pull request #9231 from itaiferber/collection-codable-conformance
Add Dictionary and Set Codable conformance
2017-05-03 11:22:30 -07:00
Dave Abrahams
d8f1caf4a6 Inline all the new low-level bits 2017-05-03 09:53:30 -07:00
Erik Eckstein
155db0a4bd Let Character literals, which fit into 64 bits, be folded into a single integer constant.
This is done by ensuring that the corresponding Character constructor is inlined. llvm will do the constant folding.
Also add a test which checks this.

It makes character literals much faster (3x improvement for the CharacterLiteralsSmall benchmark)
And it removes _a lot_ of redundant code (~80% for the CharacterLiteralsSmall benchmark)
2017-05-03 09:10:21 -07:00
Ben Cohen
d8be7ae29e Use CF for Hashing (#9203) 2017-05-03 05:42:40 -07:00
Slava Pestov
e8f4930cb5 Merge pull request #9192 from slavapestov/anyobject-removal-vol-4
AnyObject removal volume 4
2017-05-02 22:03:44 -07:00
Joe Groff
7913e9821b Merge pull request #9214 from jckarter/keypaths-32-bit
Support key paths on 32-bit platforms.
2017-05-02 20:36:07 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00