mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 09:36:45 +00:00
readhexstring and readline called the one-byte file read for every input character, copying each byte into a new vector. They now scan the bytes left in the file in one slice and advance the file by the bytes they used. The results are unchanged: the same bytes, the same boolean, the same next unread byte, from the program's own file (after the whitespace that ends the last token), a decoded buffer and a filter decoded when first read. readhexstring stops on the digit that completes the last byte and drops a lone digit at the end of the data; readline takes CR LF as one line ending, leaves the byte after a lone CR unread, and leaves the line ending unread when the line fills the string. Tests run the new readers next to copies of the byte-at-a-time loops over 13 stream forms and several hundred inputs, comparing the result and everything left to read; an image read through a readhexstring procedure is compared with the same samples given as a hexadecimal string. The import fuzz tests gain readline and a case for both operators. data_op allows clippy::cognitive_complexity. Without the allow, clippy rates it 54 against the limit of 30; with the old loops in place it passes.