mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-07 14:33:34 +00:00
push_num formatted every number with write!("{:.*}"), which runs the
exact decimal float formatter, then scanned and trimmed the text. That
formatter was about 95% of the time to export a path of 200,000
anchors.
At 9 decimals or fewer, push_num now scales the value by 10^decimals
and writes the digits of the rounded integer when that rounding is
certain: the scaled value is below 2^53 and further from a half than
the scaling's rounding error. Ties and larger values still go through
the formatter, so the output is the same byte for byte.
Exporting one path of 200,000 anchors takes a median of 43.4 ms
instead of 167.0 ms, and 20,000 rectangles 81.4 ms instead of 141.4 ms
(Windows 11, release build).