Commit Graph

113 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
Nishith Kumar M Shah
056b4943a3 Fix String.hasPrefix and String.hasSuffix when self and arg are in NFC form (#67729) 2023-08-23 11:23:59 -05:00
Hassan
1d4f220ed4 [stdlib] Replace precondition with the internal _precondition 2021-11-04 23:51:10 +02:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Xiaodi Wu
870dae5204 [docs] hasPrefix and hasSuffix don't match scalars (#22056) 2019-01-23 10:21:55 -06:00
Maxim Moiseev
e107fab25b [stdlib] Internalize _Buffer32 and _Buffer72 2018-11-07 11:25:31 -08:00
Michael Ilseman
948655e850 [String] Cleanups, comments, documentation
After rebasing on master and incorporating more 32-bit support,
perform a bunch of cleanup, documentation updates, comments, move code
back to String declaration, etc.
2018-11-04 10:42:42 -08:00
Michael Ilseman
7c00552729 [String] In-place append and other RRC improvements 2018-11-04 10:42:40 -08:00
Michael Ilseman
4ab45dfe20 [String] Drop in initial UTF-8 String prototype
This is a giant squashing of a lot of individual changes prototyping a
switch of String in Swift 5 to be natively encoded as UTF-8. It
includes what's necessary for a functional prototype, dropping some
history, but still leaves plenty of history available for future
commits.

My apologies to anyone trying to do code archeology between this
commit and the one prior. This was the lesser of evils.
2018-11-04 10:42:40 -08:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Erik Eckstein
9a961208ec stdlib: remove some @inlineables from String API functions.
Beside the general goal to remove inlinable functions, this reduces code size and also improves performance for several benchmarks.
The performance problem was that by inlining top-level String API functions into client code (like String.count) it ended up calling non-inlinable internal String functions eventually.
This is much slower than to make a single call at the top-level API boundary into the library. Inside the library all the internal String functions can be specialized and inlined.

rdar://problem/39921548
2018-05-03 14:37:11 -07: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
388622c393 [string] Small fast-path for hasPrefix/Suffix 2018-03-27 14:01:00 -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
6970238635 [gardening] code formatting; NFC 2018-03-13 15:32:20 -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
Michael Ilseman
a6e79efbbe [string] Minor simplifications 2018-03-13 15:32:19 -07: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
Xiaodi Wu
76e23368ad Consolidate integer-to-string implementations 2018-02-03 19:17:48 -06: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
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
Xiaodi Wu
9fac17e6e2 Fix bug in String(_:radix:uppercase:) 2018-01-06 03:27:17 -06:00
Nate Cook
0782b482b3 [stdlib] Documentation improvements
- Revise Equatable and Hashable for synthesized requirements
- Complete Strideable and stride(from:...:by:) documentation
- Revise DoubleWidth type docs
- Add complexity notes for Set.index(of:) and .contains(_:)
- Fix typos in Set.formUnion docs
- Add missing axioms for SetAlgebra (SR-6319)
- Improve guidance for description and debugDescription
- Add note about the result of passing duplicate keys to
  Dictionary(uniqueKeysWithValues:)
- Fix typo in BinaryInteger docs
- Update Substring docs with better conversion example
- Improve docs for withMemoryRebound and isKnownUniquelyReferenced
- Add missing docs not propagated from protocols
2018-01-05 17:06:44 -06:00
Greg Parker
da14cd79a6 [runtime] Clean up symbol exports in libc functions. (#13202) 2017-12-01 17:49:11 -08:00
Nate Cook
390d4464ad Support larger integers in String(_:radix:) 2017-11-24 22:16:30 -06: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
4a1b74c266 [stdlib] Additional revisions
- Incorporate feedback from @xwu
- Add parameters for `dump`
- Duplicate some missing integer comments
2017-09-12 11:21:54 -05:00
Maxim Moiseev
ee5fb33656 [stdlib] Remove the Grand Renaming artifacts of Swift 3 era 2017-08-28 15:54:11 -07:00
Michael Ilseman
6cb48529a9 [stdlib] Refactor out StdlibUnittest SPI from the stdlib.
Move _lines and _split out of the standard library and into
StdlibUnittest, which is why they were there in the first place. NFC.
2017-07-26 15:58:04 -07:00
Dave Abrahams
c497969987 [stdlib] Swift4 Modernizations Compatible with Swift 3.2 2017-07-14 17:54:33 -07:00
Nate Cook
8926df9bbc [stdlib] Partial implementation of DoubleWidth 2017-05-24 19:16:26 -05: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
Nate Cook
7fa74f590d [stdlib] Documentation revisions for string + ranges
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
2017-05-13 10:06:05 -05:00
Dave Abrahams
ddf7ad517f UnicodeScalar => Unicode.Scalar 2017-05-11 15:23:25 -07:00
ben-cohen
a7def4bba9 Delete old unused String._splitFirst 2017-04-30 06:04:15 -07:00
Maxim Moiseev
1c1b2b966d [stdlib] String : RangeReplaceableCollection & BidirectionalCollection (#8921)
* [stdlib] String : RangeReplaceableCollection & BidirectionalCollection

* Add source compatibility hack for Swift.max

* Add source compatibility hack for Swift.min

* Remove redundant conformance in benchmarks

* Fix stupid typo I thought I'd already pushed

* XFAIL testing now-redundant conformance

* XFAIL an IDE test for now
2017-04-23 20:04:54 -07:00
Ben Cohen
9733d50db4 Add Swift 3 compatibility versions of String.init for Signed/UnsignedInteger (#8926) 2017-04-21 17:30:31 -07:00
Max Moiseev
2f5fd8e2ed Improving benchmarks 2017-03-27 14:59:27 -07:00
Max Moiseev
27889c6376 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-06 15:54:44 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Ben Cohen
9a4349ce89 Combine String.init with and without radix 2017-01-03 18:39:59 -08:00
Max Moiseev
70b2343626 Merge branch 'master' into new-integer-protocols 2016-11-28 15:25:01 -08: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
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00
Dmitri Gribenko
77813904f8 stdlib: replace error-prone pairs of isASCII/startASCII calls with an API that returns Optional 2016-09-05 22:47:24 -07:00