`UniqueArray.replace(removing:copying:)` overloads overestimated the amount of memory they need, sometimes leading to unnecessary reallocations. Fix this.
The original code was invoking `_closeGap` with an incorrect size (from `append` rather than `replace`), leading to runtime traps and potential memory safety issues if the `resize` invocation ends up underfilling the container.
This is currently conditional on the UnstableContainersPreview trait. (Swift 6.4 has not shipped yet, so we cannot unconditionally enable this without risking breakage.)
Adds trailing underscores to the BorrowingSequence protocols and
requirements, in order to allow both parallel conformances and
the ability to evolve the requirements in this package.
This updates the ContainersPreview module to use the same
API as the proposed BorrowingSequence protocol and its supporting
types. In particular, instead of using Span as the iterator for
itself and other contiguously-stored types, this introduces
SpanIterator.
This introduces a debugging data formatter for RigidArray using a new feature of LLDB:
[Formatter Bytecode][1]. The scope of this PR is a single initial data type, with the
short and long term plan being to support all types vended by Swift Collections.
The bytecode for this implementation is produced using a Python -> Formatter Bytecode
compiler, contained in the [`formatter_bytecode`][2] module.
The workflow for authoring and shipping the formatter is:
1. Update RigidArray.py as needed
2. Compile RigidArray.py to RigidArray+Formatter.swift (again, `formatter_bytecode`)
3. Compile RigidArray+Formatter.swift as part of the BasicContainers module
By including the bytecode in the binary, lldb can load RigidArray's data formatter
automatically, without any friction that comes with installation, setup, config,
updating, or versioning.
[1]: https://lldb.llvm.org/resources/formatterbytecode.html
[2]: https://github.com/llvm/llvm-project/blob/main/lldb/examples/python/formatter_bytecode.py
“Work” in this case means that they can be enabled without breaking the build — not necessarily that all features are available.
Swift 6.2 is highly prone to runtime crashes in `swift_getTypeByMangledName` in generic code that uses ownership features. Swift 6.3 will resolve that.
Don’t just append new items to the end of storage — it misleads clients into assuming that the containers preserve insertion order, when they most certainly don’t do that.
Instead, insert new items into the middle of storage, using an extra swap.
We don’t need to calculate the probe length of the item currently occupying the new item’s ideal bucket — it cannot possibly be lower than the new item’s. This spares one hash operation during insertions that result in a hash collision.
Due to a number of cascading off-by-one errors, the maximum probe length could end up getting set lower than the actual value, _sometimes_ rendering some items unreachable.
Weirdly, the issue seems to be rare enough that it somehow never triggered in any of my previous test runs.
Oops, I lost a change that allowed enabling the UnstableHashedContainers trait without also opting into UnstableContainersPreview. Reimplement this functionality.