slist icon indicating copy to clipboard operation
slist copied to clipboard

Serializable representations with leading length

Open k0001 opened this issue 5 years ago • 1 comments

This is more of a comment for something to keep in mind in future work, rather than an issue about something that exists now in the code. I mention it now because this potential issue is easier to prevent than to correct afterwards =)

I noticed that in the internal representation for Slist, the size comes after the list itself. This is fine, there's nothing wrong with this in principle. However, when the time comes to implement serializations for values of type Slist x, such as Binary or Serialize or Serialise or ToJSON or whatever, if the serialized representations include the size of the list, please make sure the size comes before the list content, and not after. This can make parsing significantly more performant, since the expected length can be verified before even attempting to parse the entirety of the list.

Cool library!

k0001 avatar Jun 12 '20 11:06 k0001

That is an interesting point! To be honest I didn't think about that.. I don't mind having the arguments swapped in the library if it could help in the future :slightly_smiling_face:

vrom911 avatar Jun 21 '20 14:06 vrom911