Hi, #snac author here. The xs
code is specially crafted to parse the JSON files in use in the ActivityPub protocol, which are a) mostly small, and b) they have very few numbers, so the string to double conversion happens almost never.
Regarding the enum numbers: they are surely arbitrary, but the rationale there is that they are all ASCII control codes (so: less than 32) that should never happen in a JSON file (and, if they occasionally appear, they are converted to their Unicode representations). The correspondence is:
XS_TYPE_STRING 0x02 ASCII: STX (start of text)
XS_TYPE_TRUE 0x06 ASCII: ACK (acknowledge)
XS_TYPE_FALSE 0x15 ASCII: NAK (negative ack.)
XS_TYPE_LIST 0x1d ASCII: GS (group separator)
XS_TYPE_LITEM 0x1f US (unit separator)
XS_TYPE_DICT 0x1c ASCII: FS (file separator)
So, yes, they are arbitrary, but make some fucking sense, or at least a little bit.
CC:
@lizzy@social.vlhl.dev