Closed TimDiekmann closed 6 years ago
I really don't really like this. My current serialization format is meaningful to anyone familiar with the implementation details, while yours is obscured. I strongly disagree that yours is "more intuitive". Furthermore, what if a malicious actor edits the representation as such:
{
"1": 10,
"2": null,
}
This is harder to detect than what we have now, because the current serialization format inherently allows only one entry per slot.
It's more intuitive in the sense, that we have a key somewhere in the code which is mapped to a value.
SlotMap
is an unordered map. It would be neat to have a map-like serialization instead of the vector. This has some advantages:version
field from SlotSince both,
index
andversion
areu32
, the key of the map could beu64
, which contains both.Let me give an example:
With the current implementation, this would result in
With a map-like serialization, it would look like
or
depending on how to construct the key. I'd prefere the former because the keys will still be ordered by index.