This eliminates a retain/release pair around calls to it when it doesn’t get inlined.
_delete is responsible for restoring hash table invariants after a removal. It moves around elements in complicated patterns, but it doesn’t release them.
Replacing the old key with the new is unnecessary and somewhat surprising. It is also harmful to some usecases.
rdar://problem/32144087
# Conflicts:
# stdlib/public/core/NativeDictionary.swift
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.
Like before, allow the use of Cocoa indices to access native sets/dictionaries, but approximate the same mutation count-based check as we do for native indices.
- Ensure that native collections that were converted from Cocoa have an age generated from the address of the original Cocoa object.
- To get the age of a Cocoa index, regenerate one from the object embedded in it.
- Compare self.age to index.age and trap if it doesn’t match.
# Conflicts:
# stdlib/public/core/HashTable.swift
Native sets and (especially!) native dictionaries must support indexing with Cocoa indices — indices must be preserved when a Cocoa set/dictionary is converted to native.
This is especially the case for Dictionaries that were converted because of a mutation restricted to values — such as those done through the Values view.
The mutation count will allow us to recognize and trap on invalid indices more reliably. (However, it won’t be foolproof — some invalid indices may pass through the checks.)
- Change _scale to Int8 to make space for an extra Int32 without enlarging the storage header.
- Add an _age field inside the new gap.
- Initialize the age to a scrambled version of the storage address.
- Generate a new counter for every newly allocated storage instance, except for identical copy-on-write copies.
- Increment the mutation counter after every removal.
Add __consuming and __owned to Set and Dictionary members where applicable.
Ignore compiler intrinsics for casting for now — their ARC behavior is covered by unit tests that need to be updated.