structio 0.2.2
Integer reading is 38-43% faster, and a streaming block read now accepts a complex array.
[dependencies]
structio = "0.2"Changed
- Reading arrays of integers is 38-43% faster, and the representative
mixeddocument 11%. The element loop was making a function call per element, which is dearer than it sounds: the parser's cursor spilled to the stack and reloaded on every return.parse_u64now keeps a small fast path for the common short number and hands the rare cases to an out-of-line one, which is enough for the whole read to inline. Separately, JSON whitespace is answered from a table rather than a bitmask, which needed a range guard in front of it because a byte of 64 or more would shift out of the word. Against Glaze, readinguintswent from 50% to 80% andintsfrom 53% to 86%. The measurements, the two rewrites of the digit conversion that were tried first and were both slower, and the disassembly that pointed at the call rather than the digits are in docs/performance.md. No API or output change.
Fixed
-
read_array_intoandfrom_reader_arrayread a complex array. They read the typed-array tag and stopped at the extension's, so the one shape that most needs a streaming block read - a buffer of IQ samples, which a consumer can least afford to hold twice - had to go throughfrom_readerand hold the encoded document alongside the vector. The payload was always a block: interleaved(re, im)components are the in-memory form of[Complex<T>]for the same reason a typed array's payload is the in-memory form of[T]. Only the preamble differed.The aligned complex form is byte-identical to the plain one, so both arrive by the same path.
COMPLEX_ONEis refused asInvalidHeader, being a lone value with no count rather than an array, as are the six undefined forms of the class byte. A generic array staysExpectedArrayand a boolean or string array staysElementTypeMismatch. -
The big-endian conversion in the same read reverses each component rather than each element. It could not have fired before, no complex array having reached it, but a
Complex<f32>is eight bytes and reversing all eight would have transposedreandimas well as swapping the bytes of each. For every other numeric type the component is the element, so one stride serves both.
No API was added, removed or changed. Nothing needs editing to move from 0.2.1.