- Have the hash buffer include a reference to the original hash storage instance, along with a copy of its _HashTable, so that its lifetime can be independent from the deferred bridging object.
- Convert _BridgingHashBuffer to a ManagedBuffer so that we can easily put reference-counted properties in its header.
- Use _HashTable to unify low-level hashing operations across Set and Dictionary.
- Store the capacity directly inside the storage header. This allows the maximum load factor to be controlled by non-inlinable code.
- Introduce a dedicated class for the empty singleton.
- Add _BridgingHashBuffer, a standalone flat hash buffer for use in deferred bridging. Use it to eliminate the need to support non-hashable storage/wrapper variants and to improve memory use in cases where Key or Value are verbatim bridged.
- Eliminate the “TypedNative*Storage” class and _NativeSet/_NativeDictionary’s support for non-hashable keys.
- Rename storage classes as follows:
_RawNativeSetStorage ⟹ _RawSetStorage
_RawNativeDictionaryStorage ⟹ _RawDictionaryStorage
_TypedNativeSetStorage ⟹ (removed)
_TypedNativeDictionaryStorage ⟹ (removed)
_HashableTypedNativeSetStorage ⟹ _SetStorage
_HashableTypedNativeDictionaryStorage ⟹ _DictionaryStorage
The new names make it obvious which ivar layout is in use.
This allows us to move the empty NSSet/NSDictionary overrides out of the root storage class; they don’t really belong there. More importantly, it makes empty sets/dictionaries super obvious to lldb and other runtime tools.
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.
- Inlinability audit
- Create a _NativeSet/_NativeDictionary directly, without extracting it from a Set/Dictionary
- Swap the final result with an empty collection.
- 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.
- 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.
* Update std lib to Swift 5.0
* Disable Unicode.* warnings for now
* Slow path to resiliently handle the case where an unknown rounding rule is passed
* Remove resilience from Encoding/DecodingError (which should only happen on slow paths anyway)
* internal typealiases now need @usableFromInline
* Force inlining on Array._owner.get
This allows Set’s internal types not to define Key, Value, SequenceElement & SequenceElementWithoutLabels typealiases.
Splitting the protocol on the mutable/immutable axis allows us to remove some obsolete method definitions.