Fixes/Implements Must Occur serix validation for arrays.
This functionality is implemented in ReadSliceOfObjects, which is never called except in tests.
The way it's implemented trades readability and deduplication over performance. It would have been possible to implement the check on the bytes directly, which would have been more efficient than iterating separately over the slice and over the reflection types. However, obtaining the correct type denotation for the already-serialized objects is not trivial, but needed in order to read the correct number of bytes (uint8 vs uint32 for the two possible type denotations).
It would have likely also resulted in an implementation that would be integrated in the existing code, which makes it less readable and reusable.
The way it is implemented now is self-contained in a function and simply called four times from encoding/decoding and map encoding/decoding.
Type of change
Choose a type of change, and delete any options that are not relevant.
Bug fix (a non-breaking change which fixes an issue)
How the change has been tested
Tests were added.
Existing test frameworks like serializeTest and deSerializeTest were not suitable for reuse, so new ones were added.
Description of change
Fixes/Implements Must Occur serix validation for arrays.
This functionality is implemented in
ReadSliceOfObjects
, which is never called except in tests.The way it's implemented trades readability and deduplication over performance. It would have been possible to implement the check on the bytes directly, which would have been more efficient than iterating separately over the slice and over the reflection types. However, obtaining the correct type denotation for the already-serialized objects is not trivial, but needed in order to read the correct number of bytes (uint8 vs uint32 for the two possible type denotations). It would have likely also resulted in an implementation that would be integrated in the existing code, which makes it less readable and reusable.
The way it is implemented now is self-contained in a function and simply called four times from encoding/decoding and map encoding/decoding.
Type of change
Choose a type of change, and delete any options that are not relevant.
How the change has been tested
Tests were added.
Existing test frameworks like
serializeTest
anddeSerializeTest
were not suitable for reuse, so new ones were added.