mirror of
https://github.com/penpot/penpot.git
synced 2026-11-10 03:50:33 +00:00
* ✨ Cache the transit reader when decoding strings On the cljs side, we create a new transit reader on every call to decode-str. This turns out to have a fair bit overhead in both transit-cljs and transit-js, since it has to merge the handlers, call clj->js, allocate a new ReadCache, etc. By reusing it the measured decode time goes from ~58us -> ~41us, so about 1.4x faster. This particularly helps for some operations like whenever a component is edited and every object needs to be decoded, see https://github.com/penpot/penpot/issues/9344, although they could probably be made more efficient in other ways. The reader usually clears its read cache after a successful read, but whenever it throws it hangs around. So in this case we need to reset the cache ourselves, otherwise the next read will be from a clobbered cache. The tests were written by Claude Sonnet 5.5, and should cover the clobbering behaviour above. Signed-off-by: Luke Lau <luke@igalia.com> * Keep one transit reader per type and rebuild it on add-handlers! --------- Signed-off-by: Luke Lau <luke@igalia.com> Co-authored-by: Andrey Antukh <niwi@niwi.nz>