mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
SaveOptions::for_doc chose pretty-printed JSON by the object count in the layers alone. A document with few layer objects but many anchors, or with its art in symbols, patterns or graph designs, was therefore written pretty, about ten times the compact size: every anchor's "p", "in" and "out" spread over several indented lines. A document is now pretty only when it has at most PRETTY_MAX_OBJECTS objects and its compact JSON is at most PRETTY_MAX_BYTES (1 MiB). The size is measured by serializing into a writer that stops at the limit, so a large document costs at most 1 MiB of extra serializing. Small documents stay readable and diffable. Fixes #1484