Commit Graph

161 Commits

Author SHA1 Message Date
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Sho Ikeda
a35c9f0c60 [gardening] Use Collection.isEmpty over Collection.count 2019-05-26 09:35:20 +09:00
Kyle Murray
7eab74c066 [stdlib] Fix a misspelling in a Dictionary doc comment.
Fixes rdar://problem/48759246.
2019-03-18 15:34:50 -07:00
Mike Ash
fa5888fb3f [Stdlib][Overlays] Rename various classes to avoid conflicting ObjC names.
Old Swift and new Swift runtimes and overlays need to coexist in the same process. This means there must not be any classes which have the same ObjC runtime name in old and new, because the ObjC runtime doesn't like name collisions.

When possible without breaking source compatibility, classes were renamed in Swift, which results in a different ObjC name.

Public classes were renamed only on the ObjC side using the @_objcRuntimeName attribute.

This is similar to the work done in pull request #19295. That only renamed @objc classes. This renames all of the others, since even pure Swift classes still get an ObjC name.

rdar://problem/46646438
2019-01-15 12:21:20 -05:00
Nate Cook
f19aca6cb0 [WIP] Revise documentation for Swift 5 stdlib additions (#21333)
* Revise the Unicode scalar/Character properties
* Minor revisions to `compactMapValues` docs.
* Add documentation for AdditiveArithmetic, revise Numeric
* Apply minor style updates to count(where:).
* Revise string interpolation docs.

- Convert table of interpolation examples to a list of examples. Tables
aren't supported by Swift markup, so this wouldn't render properly in
Xcode or on the web.
- Add a description of what a user must implement in a custom
string interpolation type to get the behavior they want.

* Revise isMultiple(of:) docs.

- In particular, add emphasis to mathematical symbols and equations to
match how we document such things elsewhere.
- I'm using asterisks for single symbols, and underscores for equations
because it's easier to read in-source when you don't have to escape
multiplication within emphasis.

* Add some abstracts to the SIMD vector types.

- Adds a dictionary of spelled out numbers. Only numbers < 10
  should be spelled out according to editorial.
- Adds abstracts to some of the basic members.
- Includes parameter descriptions for the xyzw properties and inits,
but not for the unlabeled initializers. Combined with the protocol
extension method abstracts, this should complete coverage of the concrete
types.
2019-01-03 18:19:20 -06:00
Valeriy Van
a4496d51d8 Fixes typo in var name in example snippet (#21553)
imagePaths is declared in line 320
2019-01-02 16:21:42 -06:00
Erik Eckstein
aae60ff271 stdlib: Code size improvements for Dictionary for -Osize
The first change is to remove some @inline(__always) attributes. Those were added before we had the guaranteed-by-default calling convention. They are not necessary anymore.

The second change is to not specialize some slow-path functions. This results that no specialization code for these functions is generated at the client side. Instead those functions are directly called in the libSwiftCore.
Note that Key-related hash and equality comparisons are still specialized, because otherwise the performance hit for Osize would be too big.

Some Dictionary benchmarks regress a bit with -Osize, but the code size wins are big.

rdar://problem/46534453
2018-12-13 16:59:19 -08:00
Karoy Lorentey
ce96f1e528 [stdlib] _modify: Use defer to ensure invariants are restored when yield throws
_modify mustn’t leave Collection storage in an inconsistent state when the code to which we’re yielding happens to throw. In practice this means that any cleanup code must happen in defer blocks before the yield.

Fix Dictionary to do just that and add tests to cover this functionality (as well as some other aspects of _modify).
2018-12-05 17:35:24 +00:00
Karoy Lorentey
d32fd283b0 [stdlib] Refactor Dictionary.subscript._modify for better layering
This may also reduce ARC traffic by a little bit.
2018-11-30 17:47:08 +00:00
Ben Cohen
1673c12d78 [stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
2018-11-15 20:50:22 -08:00
Karoy Lorentey
096903732c [stdlib] Make _NSDictionaryCore, _NSDictionary internal
These shadow protocols don’t add any real type safety, and exposing them in the ABI seems unnecessary.
2018-11-15 09:54:25 +00:00
Brent Royal-Gordon
e0a267064a Improve an explanatory comment in Dictionary (#20540)
It took me a little while to figure out why we were fatalError()ing in such a convoluted way in Dictionary.init(uniqueKeysWithValues:); the next person to look at this code won’t waste that time.
2018-11-14 14:47:03 -08:00
Ben Cohen
df2307e035 [stdlib][DNM] Collapse sequence and collection wrappers (#20221)
* Concretize dropFirst/Last/sufix/prefix from Sequence

Remove split customization point

Eliminate SubSequence from Sequence protocol

Collapse LazyCollection

Collapse LazyMapCollection

Eliminate _SequenceWrapper

Collapse LazyFilterCollection

Collapse LazyDrop/PrefixWhileCollection

Fix tests, ABI stability update

Collapse FlattenSequence

* Add entries to source/ABI compatible expected results.

* Update tests to avoid pre-10.14 objc runtime bug

* Expunge _preprocessingPass
2018-11-14 10:05:58 -08:00
Ben Cohen
dbc2e21522 Remove customization points from Sequence and Collection (#19995) 2018-10-31 18:58:00 -07:00
Karoy Lorentey
803a43c537 [stdlib] Set, Dictionary: Change second word in Cocoa indices to an integer offset
_BridgeObject turned out not to be a great choice, because it doesn’t support tagged values on 32-bit platforms. Extracting the offset from index storage is a good idea anyway!
2018-10-27 01:11:59 +01:00
Karoy Lorentey
e76881fe9d [stdlib] Dictionary: Fix overrelease in key-based subscript
Also, reorganize the code. We can have multiple yields now!

https://bugs.swift.org/browse/SR-9065
2018-10-26 16:22:56 +01:00
Nate Cook
dfb01b6a6a [stdlib] Minor documentation revisions (#20045)
* [stdlib] Minor documentation revisions
* [docs] Convert 'nonoptional' to 'non-optional'
We're switching to 'non-optional' across the board, as the unhyphenated
form is too easy to read as 'no-noptional'.
2018-10-26 00:05:45 -05:00
Karoy Lorentey
d904b46554 [stdlib] Dictionary.Index: Remove duplicate definition for _isNative 2018-10-05 12:33:26 +01:00
Karoy Lorentey
697ad69d24 [stdlib] Set, Dictionary: Reorganize equality checks to fix Linux builds 2018-10-05 12:33:25 +01:00
Karoy Lorentey
73771b1ca9 [stdlib] Rework Dictionary.values._modify 2018-10-05 12:33:25 +01:00
Karoy Lorentey
12cad748d4 [stdlib] Dictionary.Values.swapAt: Fix uniqueness check 2018-10-05 12:33:25 +01:00
Karoy Lorentey
64d19f44db [stdlib] Set, Dictionary: Switch to using a _BridgeObject instead of an enum 2018-10-05 12:33:25 +01:00
Karoy Lorentey
e24f2ba6e5 [stdlib] Set, Dictionary: Flatten switch statements
The optimizer dislikes nested switch statements; flatten them out to simplify optimization and to hopefully speed things up a little.
2018-10-05 12:33:25 +01:00
swift-ci
dfed2796ae Merge pull request #19706 from airspeedswift/further-pwnage 2018-10-04 11:40:11 -07:00
Karoy Lorentey
a2e21667eb Merge pull request #19694 from lorentey/values-isnt-really-a-mutablecollection
[stdlib] Allow native dictionaries to advance Cocoa indices
2018-10-04 11:45:22 +01:00
Ben Cohen
9ce2143335 Additional ownership annotations 2018-10-03 19:10:22 -07:00
Karoy Lorentey
6e671b6631 [stdlib] Allow native dictionaries to advance Cocoa indices 2018-10-03 21:05:46 +01:00
Karoy Lorentey
20bb815b62 Merge pull request #19683 from lorentey/inline-customization-points
[stdlib] Force-inline some Sequence/Collection customization points
2018-10-03 15:43:53 +01:00
Karoy Lorentey
6cb546534e [stdlib] Dictionary: Force-inline native iterators 2018-10-03 13:23:47 +01:00
Karoy Lorentey
2f0f43a869 [stdlib] Dictionary, Set: Force-inline hidden Sequence/Collection customization points
This should eliminate a branch, which should probably lead to a tiny overall code size improvement, as well as a tiny performance boost.
2018-10-03 13:14:48 +01:00
Karoy Lorentey
5c04ebf6ae [stdlib] Force-inline Dictionary.subscript(_:, default:)._modify
Otherwise the autoclosure argument gets allocated on the heap, which leads to a 2x slowdown.
2018-10-02 14:34:57 +01:00
Karoy Lorentey
1529d37301 [stdlib] Implement formIndex(after:) in all hashed collections 2018-09-29 02:30:08 +01:00
Karoy Lorentey
526162f706 [stdlib] Set, Dictionary: Fix uniqueness checking for Cocoa indices 2018-09-29 02:29:32 +01:00
Karoy Lorentey
41bedbe42b [stdlib] Set, Dictionary: Remove inappropriate @_effects from Index hashing 2018-09-28 20:15:55 +01:00
Karoy Lorentey
900c930b4b [stdlib] Turn _CocoaDictionary.Index into a COW value type with opaque storage 2018-09-28 18:25:16 +01:00
Karoy Lorentey
d477420ee4 [stdlib] Set, Dictionary: Make Cocoa indices resilient for now 2018-09-28 15:18:15 +01:00
Karoy Lorentey
7a8b34a499 [stdlib] Set, Dictionary: Make reserveCapacity non-inlinable
This allows us to record the reserved capacity in storage later, which will enable removals to resize the hash table.
2018-09-28 04:59:33 +01:00
Karoy Lorentey
e080bab5e5 Merge pull request #19602 from lorentey/dict-iterators
[stdlib] Dictionary.Keys, .Values: Implement custom iterators
2018-09-28 04:18:15 +01:00
Karoy Lorentey
a05a66cdce [stdlib] Dictionary.Keys, .Values: Implement custom iterators 2018-09-28 02:10:17 +01:00
Karoy Lorentey
46475d03d0 [stdlib] Supplying a native index to a bridged set/dictionary is not an internal error 2018-09-27 19:11:57 +01:00
Karoy Lorentey
9a0e303ac6 [stdlib] Dictionary: Allow limited use of Cocoa indices in native dictionaries
Affected operations:

subscript(index:)
keys.subscript(index:)
values.subscript(index:) (setter and _modify)
remove(at:)
swapAt(_:, _:)

Note that index(after:) is intentionally not on this list.
2018-09-27 19:11:50 +01:00
Karoy Lorentey
656685777f [stdlib] Dictionary: Update remove(at:) and Values to allow Cocoa indices 2018-09-27 19:09:43 +01:00
Karoy Lorentey
6033454201 [stdlib] Dictionary.Values: Specialize swapAt 2018-09-27 01:49:51 +01:00
Karoy Lorentey
be68ede45b [stdlib] Dictionary.Values.subscript: Validate index in _modify accessor 2018-09-27 01:49:51 +01:00
Karoy Lorentey
e5d976de14 [stdlib] Dictionary: Embed & check the mutation count in native indices 2018-09-27 01:49:51 +01:00
Karoy Lorentey
f600426d87 [stdlib][NFC] Update comments 2018-09-27 01:49:50 +01:00
Karoy Lorentey
231fbc6218 [stdlib] Fix platforms with a non-ObjC runtime 2018-09-27 00:31:02 +01:00
Karoy Lorentey
efe6f38d40 [stdlib] _NativeDictionary.Index: Rename to “Bucket”
Update code to reflect the new name, including in method and variable names.
2018-09-27 00:12:20 +01:00
swift-ci
aca00505d9 Merge pull request #19496 from lorentey/hashing-consuming-audit 2018-09-25 11:27:59 -07:00
Ben Cohen
df995de0d6 [stdlib] Make KeyValuePairs fully inlinable (#19502)
* Move KVP into its own Swift file. Make it fully inlineable.

* Make _makeCollectionDescription an extension. Add KeyValue equivalent.
2018-09-24 17:46:32 -07:00