Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for constant keys in our Mapping type
We implement handling of constant keys (keys prefixed with `KeyPrefix::Constant`) directly in the Mapping implementation. Keys with other prefixes are inserted into the map unchanged. To make the implementation more streamlined (and potentially faster), we switch the type of `const_keys` to be a `HashSet` instead of a `Vec`, which gives us `O(1)` removal of elements (for `Mapping::remove()`). To insure integrity of the constant key tracking, We remove the `map_as_mut()` method on the Mapping implementation which would allow callers to break the constant key invariants that the other functions provide. Some functions (`insert`, `get_mut`, and `entry`) will return an Error value when called for a key that's marked constant.
- Loading branch information