Commit Graph

274 Commits

Author SHA1 Message Date
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
8b6d0f6402 [string] Aggressively form small strings.
Whenever possible, prefer the small string format. Updates creation
logic. Adds assertion on large strings that they're not intended to be
small.
2018-03-27 14:00:59 -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
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Michael Ilseman
4e573f47f8 [stdlib] Split StringProtocol out from String.swift; NFC 2018-03-13 15:34:35 -07:00
Michael Ilseman
e7c418b0fa [comments] Annotate places we don't use _StringGuts visitor. NFC
Adds some comments for sections of code that doesn't adopt the
visitation pattern, or have inefficiencies discovered as part of this
work. Additionally, mutating methods generally do not use the visitor
scheme.
2018-03-13 15:32:19 -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
884356fc0a [string] Bifurcate StringGuts inits for large strings.
In preparation for small strings optimizations, bifurcate StringGuts's
inits to denote when the caller is choosing to skip any checks for is
small. In the majority of cases, the caller has more local information
to guide the decision.

Adds todos and comments as well:

  * TODO(SSO) denotes any task that should be done simultaneously with
    the introduction of small strings.

  * TODO(TODO: JIRA) denotes tasks that should eventually happen
    later (and will have corresponding JIRAs filed for).

  * TODO(Comparison) denotes tasks when the new string comparison
    lands.
2018-03-13 15:32:19 -07:00
Paul Hudson
45b25b9b85 [Gardening] Changed lowercaseString to lowercased() in comments. 2018-03-13 09:55:33 -05:00
Ben Cohen
f9b3e14137 [stdlib] Use Swift-native Character iteration for hasPrefix/Suffix (#14390)
* Use Swift-native Character iteration for hasPrefix/Suffix

* Remove old tests for removed C shims
2018-03-12 17:41:55 -07:00
Nate Cook
642cbbad7c [stdlib] Documentation revisions and expansions
- Adding docs for unbounded ranges
- Filling in missing docs for range-expression subscripts
- Equality operators for arrays
- Fix issues with range discussions
- Fill in missing integer docs
2018-02-19 11:49:58 -06:00
Michael Ilseman
9948141a99 [gardening] Strip trailing whitespace; NFC 2018-02-01 12:10:25 -08:00
Michael Ilseman
9a87d24bc7 [string] Workaround fail emptySingleton check.
This is a temporary workaround for some situations where the empty
singleton is not being formed correctly (and this seems to be highly
configuration dependent). Work around that for now for also checking
for empty non-storage-backed Strings.

This is probably too expensive a check for us to do long-term, but it
works for now.
2018-01-22 11:07:52 -08:00
Karoy Lorentey
90e894729a [StringGuts] Linux support
Add support for compiling StringGuts without the Objective-C runtime.
2018-01-21 12:37:36 -08:00
Karoy Lorentey
5cf9fd7414 Remove _StringBuffer 🎉🎉🎉 2018-01-21 12:35:15 -08:00
Karoy Lorentey
b360bd6d69 Remove _LegacyStringCore 🎉🎉🎉 2018-01-21 12:35:15 -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
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08:00
Nate Cook
0b62b0608d [stdlib] Doc revisions
- Add missing docs & parameter lists
- Remove deprecated `characters` usage in examples
- Revise documentation for Mirror and CVarArg
- Revise documentation for swap(_:_:)
- Various typo and grammar fixes
2017-11-07 11:11:23 -06:00
Valentin Pertuisot
4b9d5d54db Improve lowercased comments documentation (#12579)
Differentiate better between a full string character lowercased and a first character only lowercased
2017-10-24 13:11:00 -05:00
Doug Gregor
772352e524 Add requirement StringProtocol.SubSequence : StringProtocol 2017-10-01 15:08:23 -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
swift-ci
79a3f9c415 Merge pull request #11670 from natecook1000/nc-rev-77-2 2017-09-19 10:15:59 -07:00
Nate Cook
050268d876 [stdlib] Documentation revisions
- Update NSRange -> Range guidance
- Fix example in Optional
- Improve RangeExpression docs
- Fix issue in UnsafeRawBufferPointer.initializeMemory
- Code point -> scalar value most places
- Reposition the dot above the scripty `i'
- Fix ExpressibleByArrayLiteral code sample
2017-08-29 09:41:55 -05:00
Maxim Moiseev
ee5fb33656 [stdlib] Remove the Grand Renaming artifacts of Swift 3 era 2017-08-28 15:54:11 -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
Nate Cook
a7ce287a53 Merge branch 'master' into integers-revised 2017-07-28 12:23:48 -05:00
Maxim Moiseev
2ba6cc9bd6 Merge pull request #11157 from airspeedswift/stringprotocolify
[stdlib] Switch Int/Float inits + join to be on StringProtocol
2017-07-27 14:22:25 -07:00
Maxim Moiseev
a5ff35cd41 [stdlib] extendingOrTruncating: => truncatingIfNeeded: 2017-07-26 11:09:36 -07:00
Michael Ilseman
2f0dafbac3 Merge pull request #11191 from milseman/very_persistent
[stdlib] Fix bug in Substring's _persistentContent
2017-07-26 08:57:53 -07:00
Omar Sharif Fathi
888fe8df3d Update String.swift 2017-07-26 02:40:45 +02:00
Ben Cohen
92bc5b7829 Switch Int/Float inits + join to be on StringProtocol 2017-07-25 08:28:22 -07:00
Michael Ilseman
b37417bdb5 [String] Delete dead code; NFC 2017-07-24 16:09:54 -07:00
Max Moiseev
5f1c3f7021 [overlay] Generalize Foundation StringProtocol extensions 2017-07-07 15:34:56 -07:00
Max Moiseev
1a1c1a0d21 [stdlib] StringProtocol no longer refines RangeReplaceableCollection
https://bugs.swift.org/browse/SR-5379
2017-07-06 09:40:10 -07:00
Maxim Moiseev
a31e2bde14 Merge pull request #10097 from apple/stringprotocol-reform
[stdlib] Eliminate over-constraint on StringProtocol
2017-06-14 15:13:56 -07:00
Nate Cook
825e9d077d [stdlib] More documentation revisions / consistency fixes. 2017-06-13 14:08:00 -05:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Dave Abrahams
eb04df45f4 [stdlib] Eliminate over-constraint on StringProtocol 2017-06-03 17:18:20 -07:00
Roman Levenstein
ecff16cba3 Reduce code size of the stdlib
This should reduce the code size of the stdlib by 1.5%.
2017-06-03 14:22:12 -07:00
Ben Cohen
d0c0043f93 [stdlib] Use ephemeral string for substring comparison (#10009)
* Use _ephemeralString for substring comparison

Add back != for String/Substring comparison

* OK fine, Linux, if you're going to be difficult

* Different forms of comparison, tests
2017-06-03 11:20:01 -07:00
Roman Levenstein
00d663d172 [sil-generic-specializer] Add @_semantics("optimize.sil.specialize.generic.partial.never") to disable partial specialization on functions
This new @_semantics is used to annotate some very big functions in the standard library. It reduced the code size of the stdlib by 2%.
2017-06-01 16:33:18 -07:00
Dave Abrahams
4f5e14845b [stdlib] Eliminate optionals from specialization code
Apparently this makes the optimizer happier.  Still waiting on #9792 for truly
efficient specialization.

https://github.com/apple/swift/pull/9792
2017-05-22 15:59:43 -07:00
Dave Abrahams
d6fee05375 [stdlib] Enable interchange among StringProtocol models 2017-05-17 17:21:43 -07:00
Maxim Moiseev
8876655f6b [stdlib] Reverting the String.init?(_: String) behavior (#9659) 2017-05-17 13:56:15 -07:00
Nate Cook
817a1efa3b [stdlib] Documentation revisions
- remove additional 'characters' references from String docs
- improved language around escaping pointer arguments
- key path type abstracts
- codable type abstract revisions
- a few more NSString API fixes
2017-05-17 11:58:08 -05:00