Commit Graph

5263 Commits

Author SHA1 Message Date
swift-ci
e5abbe8afa Merge pull request #18960 from DougGregor/prefix-postfix-inc-dec 2018-08-24 14:51:35 -07:00
Ben Cohen
293da8fa3e [stdlib] YAIAPR (#18956)
* Scrap Comparable conformance for _SwiftNSOperatingSystemVersion

* Lazy performance needs specialization

* Uninline dump/stdout

* Bool consistency

* fixup CollectionOld

* Uninline printing functions
2018-08-24 14:00:19 -07:00
Doug Gregor
61d1ab9ea1 [Standard library] Reintroduce operator declarations for pre/postfix ++/--.
The removal of these operator declarations caused a source
compatibility break, because some Swift code is defining prefix or
postfix ++/-- functions without defining the ++ or --
operators. Reinstate the operator declarations in the standard
library... but not any of the functions.

Fixes rdar://problem/43258773.
2018-08-24 13:45:50 -07:00
Johannes Weiss
bd2de10057 Builtin.isbitwisetakable 2018-08-24 16:03:38 +01:00
Ben Cohen
dd2f3b4386 [stdlib] More inalienable auditing (#18925)
* Removing FIXME from methods also marked always/never

* Unavailable/deprecated things don't need inlining

* Trivial implementations

* Enum namespaces

* Unsafe performance of opaque/raw pointer

* Dump doesn't need to be fast

* Error paths shouldn't require inlining

* Consistency with surrounding code

* Lazy performance needs specialization
2018-08-23 18:52:21 -07:00
Erik Eckstein
7c06d4f8ab Remove the pinning built-ins.
They are not used anymore after removing the pinning adressors.
2018-08-23 12:47:56 -07:00
Erik Eckstein
6ba45473df Remove the pinning addressors
It was used for Array + related types.
With exclusivity checking the pinned addressors are not useful anymore.

rdar://problem/35401528
2018-08-23 12:47:56 -07:00
Jordan Rose
9f7d6cea68 [stdlib] Mark two types @usableFromInline; they satisfy requirements (#18862)
Otherwise, the textual interface won't see them, and any inlinable
code that wants to make use of the protocol might get confused.
We should have a check for this in the compiler itself, but for now
I'm just providing this change to get unblocked.
2018-08-21 09:40:56 -07:00
Joe Groff
d3bd01e8c8 Merge pull request #18804 from jckarter/identity-key-path
Runtime support for identity key paths.
2018-08-20 18:04:17 -07:00
Graydon Hoare
d8140bc652 Revert "Remove some FIXME(ABI) redundant entries from the Collection hierarchy (#18830)"
This reverts commit b3c17bd333.
2018-08-20 14:38:30 -07:00
Joe Groff
44b55ae197 Runtime support for identity key paths.
Make sure the implementation can handle a key path with zero components by removing inappropriate assumptions that the number of components is always non-empty. Identity key paths also need some special behavior:

- Appending an identity key path should be an identity operation for the other operand
- Identity key paths have a `MemoryLayout.offset(of:)` zero
- Identity key paths interop with KVC as key paths to `@"self"`

To be able to exercise and test this behavior, add a `Builtin.identityKeyPath()` function and `WritableKeyPath._identity` accessor in lieu of finalized syntax.
2018-08-20 14:00:46 -07:00
Ben Cohen
b3c17bd333 Remove some FIXME(ABI) redundant entries from the Collection hierarchy (#18830) 2018-08-20 07:11:40 -06:00
Ben Cohen
bd310140f3 [stdlib] Modernize sort code (#18824)
* Replace bodies of Comparable versions with calls to sort(by:)

* Make _insertionSort a method

* Make _sort3 a method

* Make _partition a method

* Make _introSort a method

* Make _siftDown, _heapify, _heapsort methods

* Other minor cleanup
2018-08-19 11:36:10 -06:00
Kyle Murray
29c8329bee [stdlib] Document that removeAll(where:) doesn't reorder the remaining elements. (#18803)
* Document that removeAll(where:) doesn't reorder the remaining elements.

Per Swift Forums discussion on the topic:
"Does removeAll(where:) on arrays guarantee preserved order of elements?"

* Copy docs from the first default impl up to the protocol requirement.

Per Nate's feedback on PR#18803.

The protocol requirement was missing a few extra sentences and a
code example.

* Fix a code example that would fail to remove negative odd integers.

Per feedback on the forums from Jens,
swap `== 1` with `!= 0` so that negative odd numbers would be
removed, too, if the example were modified to include some negative
numbers in the input array.
2018-08-18 11:03:33 -06:00
Joe Groff
47f046ef52 Merge pull request #18768 from jckarter/keypath-let
Preserve 'let'-ness of stored properties in key paths.
2018-08-17 14:32:30 -07:00
Joe Groff
70c60e5186 KeyPaths: Make references to let properties properly immutable. 2018-08-17 10:59:36 -07:00
Karoy Lorentey
c88030faa0 Merge pull request #18181 from lorentey/dictionary-review
[stdlib] Modernize Set and Dictionary internals
2018-08-17 14:49:42 +01:00
Kirill Chibisov
9c5f9ce18d [stdlib][QoI] Replace recursion in sort _siftDown with Iteration (#18629)
* stdlib: replace recursion in _siftDown with iteration

Iterative approach removes recursion overhead. Therefore performance
of sorting will be improved
2018-08-16 18:39:18 -06:00
Karoy Lorentey
d1ec3b9b9b [stdlib] Make Set.isSubset(of:) self-contained; remove standalone function for same 2018-08-16 21:35:24 +01:00
Karoy Lorentey
d2d3c0cb21 [stdlib] Implement Set.contains without retrieving the stored value 2018-08-16 21:35:24 +01:00
Joe Groff
00b50ce6ab KeyPaths: Take a bit for encoding "let"-ness of stored properties.
If we know a key path component can be accessed as a stored property, then we should also know whether it's a `let` or not, so it should be safe to encode this in the key path pattern. Stage this change in by changing the number of bits used to store in-line offsets, fixing up the parts of the key path implementation that assumed that it took up the entire payload bitfield.
2018-08-16 13:21:15 -07:00
Joe Groff
c11aacc576 KeyPaths: Put an override shim on swift_getKeyPath.
This will let future compilers that support new key path features backward-deploy logic for interpreting new kinds of key path patterns.
2018-08-16 13:15:21 -07:00
Karoy Lorentey
2213b4ee2d [stdlib] Set, Dictionary: Review _SwiftDeferredNS* 2018-08-16 20:05:32 +01:00
Karoy Lorentey
548f59a0e3 [stdlib] Set, Dictionary: Make internal representations conform to Sequence 2018-08-16 20:05:32 +01:00
Karoy Lorentey
5e969ce24c [stdlib] Set, Dictionary: Simplify _find(_:,startBucket:)
The startBucket argument is _bucket(key) in the vast majority of cases. Add an overload with this default value.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
b1c81e5ffe [test] Update api-digester source compatibility tests
DictionaryIterator & SetIterator have been renamed Dictionary.Iterator and Set.Iterator, with compatibility typealiases.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
3bb720c6b0 [stdlib] Set, Dictionary: Prefer collection-agnostic names for stored property names
This makes it easier to define lldb data formatters for these types.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
9eb2743dd9 [stdlib] _UnsafeBitMap: make internal; force-inline members
A Dictionary.removeValue(forKey:) benchmark regressed 35% because recent changes in this PR caused an _UnsafeBitMap member to not be inlined in its implementation. (This was probably triggered by moving a method from Dictionary._Variant to _NativeDictionary.)
Add @inline(__always) to _UnsafeBitMap members.

While we’re at it, make _UnsafeBitMap @usableFromInline. It’s only public for testing purposes.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
063d92627b [stdlib] Dictionary: Add implementation for first
This is primarily for documentation purposes, although the default implementation (based on an iterator) may not return the correct value for bridged dictionaries with exotic implementations.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
6ee9fce52c [stdlib] Set, Dictionary: Remove remaining internal typealiases 2018-08-16 20:05:32 +01:00
Karoy Lorentey
2201d0e3c8 [stdlib] Set, Dictionary: Move compatibility typealiases to end of file 2018-08-16 20:05:32 +01:00
Karoy Lorentey
791d29f422 [stdlib] Set, Dictionary: Audit one more round of inlinability attributes 2018-08-16 20:05:32 +01:00
Karoy Lorentey
ad3c970054 [stdlib] Set, Dictionary: Review builders
- Inlinability audit
- Create a _NativeSet/_NativeDictionary directly, without extracting it from a Set/Dictionary
- Swap the final result with an empty collection.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
3f9cd3fb4b [stdlib] Set, Dictionary: Review iterators
- DictionaryIterator => Dictionary.Iterator
- SetIterator => Set.Iterator

- Introduce an explicit struct for native iterators
- _CocoaDictionaryIterator => _CocoaDictionary.Iterator
- _CocoaSetIterator => _CocoaSet.Iterator
- Move representation enums under {Set,Dictionary}.Iterator as _Variant.
- Inlinability audit
2018-08-16 20:05:32 +01:00
Karoy Lorentey
e588f1a8ba [stdlib] Set, Dictionary: Audit inlinability of storage classes
- Remove @inlinable from @objc methods.
- _UnmanagedAnyObjectArray: make internal.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
fcadebc02b [stdlib] Set, Dictionary: Review indices
- Nest native/cocoa index types under their corresponding struct
- Move *IndexRepresentation enums under the corresponding Index type, renamed to _Variant.
- Rename Index._value to Index._variant.
- Remove internal typealiases.
- Remove underscore prefix from enum case names.
- _nativeIndex => _asNative, _cocoaIndex => _asCocoa
- Audit inlinability.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
ac9f29451f [stdlib] Set, Dictionary: Review enumerators
_NativeSetNSEnumerator => _SwiftSetNSEnumerator
_NativeDictionaryNSEnumerator => _SwiftDictionaryNSEnumerator
2018-08-16 20:05:32 +01:00
Karoy Lorentey
e2fb468b97 [stdlib] Set, Dictionary: Review native & cocoa representations
- Remove buffer suffix from type, property & variable names
  struct _NativeSetBuffer => _NativeSet
  struct _NativeDictionaryBuffer => _NativeDictionary
  struct _CocoaSetBuffer => _CocoaSet
  struct _CocoaDictionaryBuffer => _CocoaDictionary

- Remove internal typealiases related to these types
- Move nativeDelete, nativeMapValues from variant enum to corresponding struct
2018-08-16 20:05:32 +01:00
Karoy Lorentey
cc8e378319 [stdlib] Set, Dictionary: Remove obsolete operator definitions. 2018-08-16 20:05:32 +01:00
Karoy Lorentey
2053f74828 [stdlib] Set, Dictionary: Review variant enums
- Rename variant enum types and move them into the corresponding struct:
  _VariantSetBuffer => Set._Variant
  _VariantDictionaryBuffer => Dictionary._Variant

  I found the buffer suffix did not positively contribute to understanding these types. And the extra indirection of the typealiases wasn't exactly helpful, either.

- Remove internal typealiases that resolved to these.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
c74e4daa2b [stdlib][NFC] Shorten notes about SR-6437 2018-08-16 20:05:32 +01:00
Ding Ye
d5d17fa38a Fix warnings for the rest of stdlib 2018-08-16 17:37:08 +10:00
Arnold Schwaighofer
8993b0d10d Address review comments 2018-08-15 07:05:47 -07:00
Arnold Schwaighofer
b9b6362251 Re-enable inlining of the _stdlib_isOSVersionAtLeast macro 2018-08-14 13:42:55 -07:00
Michael Ilseman
b93a351c89 Merge branch 'master' into patch-1 2018-08-11 18:51:29 -07:00
Michael Ilseman
9825111d00 Merge pull request #18642 from milseman/you_see_dee
[string] Internal Unicode.Scalar.withUTF16CodeUnits
2018-08-11 14:37:59 -07:00
Thomas Roughton
839d92b247 [stdlib] UnicodeScalarProperties: use RawValue over UInt32
On Windows, `__swift_stdlib_UNumericType` and `__swift_stdlib_UCharCategory` are imported as `Int32`s rather than `UInt32`. Change the constructors to use the type's inferred `RawValue` rather than always `UInt32`.
2018-08-11 12:01:19 +12:00
Ben Cohen
48e298a589 [stdlib] Remove vestigial _DisabledRangeIndex associated type (#18419)
* Remove vestigial _DisabledRangeIndex associated type

* Remove _DisabledRangeIndex from Integer types
2018-08-10 17:34:43 -06:00
Michael Ilseman
9f6eecb1ef [string] Internal Unicode.Scalar.withUTF16CodeUnits
Clean up Unicode.Scalar.Properties a bit and add internal methods to
access UTF-16 and UTF-8 code units by pointer. NFC.
2018-08-10 16:22:49 -07:00
Stephen Canon
2f015ce574 Conform Float80 to CustomReflectable. (#18577)
Fixes SR-8492.
2018-08-08 19:34:17 -04:00