Commit Graph

4494 Commits

Author SHA1 Message Date
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
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
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
Mox Soini
c66e136c18 Improve documentation for compactMapValues() of Dictionary (#18547) 2018-08-08 00:25:49 -05:00
Nate Cook
efb0415a61 [stdlib] More documentation revisions (#18263)
- Fix error in `last(where:)` example
- Improve MemoryLayout, UnsafePointer, and integer operator discussions
- Clean up ranges and random APIs
- Revisions to overflow operators and the SignedNumeric requirements
- Standardize on 'nonoptional' in remaining uses
2018-08-08 00:25:09 -05:00
Xiaodi Wu
0dcaff99eb Merge pull request #18511 from xwu/simplify-fp-int-conversion
[stdlib] Simplify concrete floating-point-to-integer conversion
2018-08-07 23:02:59 -04:00
Xiaodi Wu
c2ed788dad [stdlib] Restore rounding-based test of numeric conversion exactness 2018-08-07 21:29:51 -04:00
eeckstein
1ccad42482 Merge pull request #18520 from eeckstein/utf8iterator
stdlib: mark the UTF8View iterator's next function as inline-always.
2018-08-06 13:38:16 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Erik Eckstein
93e7786161 stdlib: mark the UTF8View iterator's next function as inline-always.
This speeds up C-String handling

rdar://problem/42247427
2018-08-06 10:28:32 -07:00
Xiaodi Wu
44f02a2fd1 [stdlib] Simplify fp-to-int and int-to-fp conversion 2018-08-04 15:36:38 -04:00
Michael Ilseman
8294c0003a [string] Drop _StringGuts subscript; NFC
_StringGuts shouldn't expose a subscript, implying efficient
access. Switch to the explicit code unit fetch method. Update tests
accordingly, and switch off of deprecated typealiases.
2018-08-02 16:34:22 -07:00
Michael Ilseman
ced2e63d95 [test] Make string internal testing a little more robust; NFC
Add an isSmall query to Character so testing doesn't have to bake in
internal format. Clarify the purpose of the invalid UTF-16 backdoor
creation method.
2018-08-02 16:34:19 -07:00
swift-ci
84909c68db Merge remote-tracking branch 'origin/master' into master-next 2018-08-02 13:29:01 -07:00
Michael Ilseman
336ae86bc5 [string] Un-break Linux build 2018-08-02 10:17:03 -07:00
Michael Ilseman
ba6158d74e [test] Internalize _StringGuts; Add shared testing struct; NFC
Create a _StringRepresentation struct to standardize internal testing
on. Internalize much of _StringGuts, except for some SPI hacks, and
update tests to use _StringRepresentation.
2018-08-01 14:23:56 -07:00
Michael Ilseman
1859ae404a [test] Internalize SmallString; NFC 2018-08-01 14:23:56 -07:00
swift-ci
bf137ae65b Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 18:59:26 -07:00
Michael Ilseman
d3f7a1615b [stdlib] Eviscerate MigrationSupport String impl
Remove many of the implementations of obsoleted String functionality
by replacing it with unreachable. A few remain temporarily until the
Foundation overlay can be updated.

Also, update TestJSONEncoder.swift off of deprecated functionality.
2018-07-31 15:42:22 -07:00
swift-ci
8247c2ba15 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 13:09:54 -07:00
Joe Groff
f8e5ebe873 Merge pull request #18299 from jckarter/enable-key-path-resilience
Enable key path resilience.
2018-07-30 13:00:43 -07:00
swift-ci
be19f650fd Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 10:08:59 -07:00