Commit Graph

152 Commits

Author SHA1 Message Date
Michael Ilseman
4a368ab46c [string] Drop many @inlinable from big API.
Drop append-related @inlinable annotations for String, StringGuts,
StringStorage, and the Views. Drop several for larger operations, such
as case conversion. Drop as many as we can from StringGuts for now.
2018-05-13 07:38:55 -07:00
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
93d6130066 [string] Integrate small strings.
Switch StringObject and StringGuts from opaquely storing tagged cocoa
strings into storing small strings. Plumb small string support
throughout the standard library's routines.
2018-03-27 14:00:59 -07:00
Michael Ilseman
1229af8e0f [string] Adopt _StringGuts visitor pattern.
Use the visitor pattern in most of the opaque-by-hand call
sites. Inspecting the compiler output does not show excessive and
unanticipated ARC, but there may need to be further tweaks.

One downside of the visitor pattern as written is that there's extra
shuffling around of registers for the closure CC. Hopefully this will
also be fixed soon.
2018-03-13 15:32:19 -07:00
Michael Ilseman
12fe85fad1 [string] Establish opaque branching pattern.
Stop inlining _asOpaque into user code. Inlining it bloats user code
as there's a bit-test-and-branch to a block containing the _asOpaque
call, followed up some operations to e.g. manipulate the range or
re-align the calling convention, etc., followed by a final branch to
opaque stdlib code.

Instead, branch directly into opaque stdlib code. In theory, this
means that supporting all opaque patterns can be done with minimal
bloat. On ARM, this is a single tbnz instruction.
2018-03-13 15:32:19 -07:00
Michael Ilseman
444796a66b [gardening] Strip trailing whitespace; NFC 2018-03-13 15:32:19 -07:00
Connor Wakamo
a2aacd73dd [stdlib] Deprecated PlaygroundQuickLook and CustomPlaygroundQuickLookable.
Deprecated the `PlaygroundQuickLook` enum and `CustomPlaygroundQuickLookable`
protocol. These are being targeted for removal in Swift 5, so we want to
unconditionally deprecate them now to encourage use of
`CustomPlaygroundDisplayConvertible` instead.

This commit includes deprecated the various `CustomPlaygroundQuickLookable`
conformances across the standard library and overlay libraries.
2018-02-21 13:38:31 -08:00
Michael Ilseman
3be2faf5d3 [String] Initial implementation of 64-bit StringGuts.
Include the initial implementation of _StringGuts, a 2-word
replacement for _LegacyStringCore. 64-bit Darwin supported, 32-bit and
Linux support in subsequent commits.
2018-01-21 12:32:26 -08:00
Michael Ilseman
75463e30f3 [stdlib] Rename _StringCore to _LegacyStringCore. NFC.
In grand LLVM tradition, the first step to redesigning _StringCore is
to first rename it to _LegacyStringCore. Subsequent commits will
introduce the replacement, and eventually all uses of the old one will
be moved to the new one.

NFC.
2018-01-21 12:28:56 -08:00
Ben Cohen
9361a6b66f [stdlib] Nest Iterator and Index types for various stdlib types (#13489)
* Nest various top-level Iterator and Index types, and flatten extensions.

* Fix tests from nesting iterator

* Nest Unsafe*BufferPointer.Iterator, extensionify UnsafeBufferPointer

* Degyb LazyCollection

* Nest Flatten iterator and index
2017-12-18 15:27:35 -08:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Michael Ilseman
2415a4df52 [stdlib] Drop Unicode 8 tries in stdlib (entirely)
This drops the last vestage of Unicode 8 tries from the standard
library. Switches everything over to use ICU.
2017-08-09 19:17:56 -07:00
Nate Cook
a51e32ad37 [stdlib] String API revisions
- Clarify StringProtocol conformance
- Deprecate ExpressibleByStringInterpolation
- String index conversions docs
- Describe shared string indices
2017-07-31 10:56:54 -05:00
Dave Abrahams
41c53ae729 [stdlib] Give Substring its own views
This necessary for ensuring the property that String doesn't keep
inaccessible memory alive.  For example, before this change,

    String(s.dropFirst().unicodeScalars)

would compile and produce a String that owned inaccessible memory.
Now it no longer compiles.

String's view's SubSequences are the same as the Substring's
view. E.g. String.UnicodeScalarView.SubSequence is
Substring.UnicodeScalarView.

New compatibility inits added, to work around the fact that many
previously failable initializers are now non-failable.
2017-07-26 15:59:51 -07:00
Dave Abrahams
38828872b9 [stdlib] Add missing unwraps for backward compatibility
Otherwise, the result would have been an infinite recursion.
2017-07-14 15:30:06 -07:00
Dave Abrahams
4f71d9e35c [stdlib] Spot fix for https://bugs.swift.org/browse/SR-5401
The simplest way to keep the string buffer alive is simply to always grab its
iterator, even if we're not going to use it.  Thanks @milseman for that idea and
@jckarter for the diagnosis help!
2017-07-11 14:58:29 -07:00
Dave Abrahams
9159239995 Un-revert "[stdlib] String index interchange, etc." (#10812)
I failed to merge the upstream changes to swift-corelibs-foundation at the same
time as I merged that #9806, and it broke on linux. Going to get it right this
time.
2017-07-07 12:13:25 -07:00
Xi Ge
d9fb110674 Revert "[stdlib] String index interchange, etc." (#10812)
rdar://33186295
2017-07-07 12:03:16 -07:00
Dave Abrahams
b1d2f4c68e [stdlib] String index interchange, part III (UTF8) 2017-07-07 06:15:24 -07:00
Dave Abrahams
2e0bb2f533 [stdlib] String index interchange, part II (UTF16) 2017-07-07 06:15:23 -07:00
Dave Abrahams
e523c80339 [stdlib] Index interchange, part I 2017-07-07 00:59:04 -07:00
Dave Abrahams
d6fee05375 [stdlib] Enable interchange among StringProtocol models 2017-05-17 17:21:43 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Nate Cook
f650e0a7da [stdlib] String and range expressions
* finish string documentation revisions
* revise examples throughout to use range expressions instead of e.g.
  prefix(upTo: _)
2017-05-13 10:06:12 -05:00
Dave Abrahams
ddf7ad517f UnicodeScalar => Unicode.Scalar 2017-05-11 15:23:25 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Nate Cook
c2bc72d9d6 [stdlib] Fix string index sharing (#4896)
* [stdlib] Fix String.UTF16View index sharing

* [stdlib] Fix String.UnicodeScalarView index sharing

* [stdlib] Fix String.CharacterView index sharing

* [stdlib] Test advancing string indices past their ends

* [stdlib] Simplify CharacterView ranged subscript
2016-10-13 10:19:38 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
Dmitri Gribenko
d1801be1ef stdlib: add a couple of ABI FIXMEs to String implementation
We should not make grapheme segmentation algorithm inlineable now (and
possibly ever).  The immediate reason is that Unicode 8.0 grapheme
segmentation algorithm has been changed significantly in Unicode 9.0.
Unicode 9.0 requires a stateful algorithm.  Current indices and
iterators just don't have the storage for that state, so we can't mark
them as fragile.
2016-08-10 18:05:29 -07:00
Andrew Trick
9886e4ef54 Use UnsafeRawPointer in StringCore.
This is another necessary step in introducing changes
for SE-0107: UnsafeRawPointer.

UnsafeRawPointer is great for bytewise pointer operations.

OpaquePointer goes away.

The _RawByte type goes away.

StringBuffer always binds memory to the correct CodeUnit
when allocating memory.

Before accessing the string, a dynamic element width check
allows us to assume the bound memory type.

Generic entry points like atomicCompareExchange no longer handle
both kinds of pointers. Normally that's good because you
should not be using generics in that case, just upcast
to raw pointer. However, with pointers-to-pointers
you can't do that.
2016-07-27 09:07:35 -07:00
Xin Tong
9709b0e510 Merge pull request #3662 from trentxintong/unicodescalar
SE-0128 - Change unicodescalar initializer to failable
2016-07-26 16:44:14 -07:00
Xin Tong
bbf86865d6 Change unicodescalar to failable
We were using a precondition which crashes the program when invalid input is
provided. We want to provide a way to gracefully check and handle invalid input
or shutdown the program if necessary.

SR-1930
2016-07-21 15:27:13 -07:00
Doug Gregor
0bf7c005b3 [SE-0091 Follow-up] Move global operators for non-generic concrete types into the type.
In various cases where we had global operators for non-generic
concrete types (such as String + String), move those operators into
the type. This should not affect the sources, but makes the exposition
of the library cleaner.

Plus, it's a good test for the compiler, which uncovered a few issues
where the compiler was coupled with the library.
2016-07-21 12:54:27 -07:00
Nate Cook
c9278a1b50 [stdlib] Remove _StringCore from UTF8View.Index 2016-07-12 09:29:40 -05:00
Dmitri Gribenko
ce94bd9cca Merge pull request #3268 from natecook1000/nc-scalarindex-nocore
[stdlib] Remove _StringCore from UnicodeScalarIndex
2016-07-07 17:41:36 -07:00
Nate Cook
2d75c12c2d [stdlib] Remove _StringCore reference from UnicodeScalarIndex
This removes the `_core` property from UnicodeScalarView.Index
and moves any remaining index-moving logic from the index to
the view in UnicodeScalarView and CharacterView.
2016-07-02 23:16:22 -05:00
practicalswift
5d1af107a3 [gardening] Use "{let,var} c: C" instead of "{let,var} c : C"
Inspired by @gribozavr:s fix in 1ad666742e
2016-07-01 23:51:32 +02:00
practicalswift
af9786efc2 [gardening] Remove duplicate words. 2016-06-04 23:16:27 +02:00
Rintaro Ishizaki
668b9dbc64 [stdlib] Apply tail style "where" clause to stdlib/public/core 2016-06-02 12:00:55 +09:00
Patrick Pijnappel
daec2dae00 Resolve conflicts with master 2016-05-24 19:21:04 +02:00
Nate Cook
44b2d56a7f [stdlib] Revise documentation for string-related types
This documentation revision covers a large number of types & protocols:
String, its views and their indices, the Unicode codec types and protocol,
as well as Character, UnicodeScalar, and StaticString, among others.

This also includes a few small changes across the standard library for
consistency.
2016-05-22 03:04:22 -05:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
Patrick Pijnappel
4419614be4 Move post-nil guarantee to separate line for Iterators' next() 2016-05-08 21:36:39 +02:00
Patrick Pijnappel
ab9e74cba3 Resolve conflicts with upstream 2016-05-05 08:55:34 +02:00
Dave Abrahams
9bee5d182f [stdlib] location/formLocation => index/formIndex 2016-04-26 17:46:16 -07:00