- Switch to using `ManagedBuffer` to represent node storage. This has
useful performance benefits, but it significantly complicates access
to node data. We no longer have direct access to the underlying raw
storage: everything needs to go through closures passed to
`ManagedBuffer.withUnsafeMutablePointers`.
- Introduce `struct _Node` and `struct _Node.UnsafeHandle` to
represent a (strong) reference to a hash tree node, and a
convenient handle for node storage, respectively. Use these instead
of directly accessing the ManagedBuffer object, whenever feasible.
- Implement separate paths for in-place mutations vs copy-on-write
operation, optimizing both flavors.
- Go to great lengths to eliminate unnecessary retain-release traffic,
whenever possible.
- Push subtree counts into parent nodes by moving the corresponding
field from the node header into the `_Node` struct. (This results in
a cool ~20x speedup for jumping around in the tree by integer
offsets.)
- Implement a type-punned empty root singleton, to allow creating
empty trees without allocating anything.
The original approach was a good one — gluing the level (aka shift) onto the hash value isn’t helpful when we’re passing around multiple hashes. The current level also seems like an important enough concept to keep as a standalone parameter.
These provide nicer tools for slicing up hash values and dealing with node bitmaps.
_Bucket is a logical entry in the hash table inside a node.
_Bitmap is a set of bucket values, represented by a bitset.
_HashPath facilitates slicing up a hash value into a series of bucket values.
_HashValue represents a hash value.
This is still just mostly superficial refactoring, with little to no functional changes.
This is just to prevent these from getting turned into global variables that are initialized on first access, especially once we make things inlinable.
(I expect these will all get moved under some type eventually.)
- DictionaryKeyValueTupleIterator → PersistentDictionary.Iterator
- DictionaryKeyValueTupleReverseIterator → PersistentDictionary.ReverseIterator
The latter type is unused. Moved under the Unused folder for now.
Follow the Standard Library coding style:
- Hard 80 character line limit
- Use two spaces as the indentation unit
- Overlong lines broken up by adding line breaks at the following places
1. After opening delimiters & before closing delimiters
2. Between each item in a list
3. Extracting subexpressions etc as needed