automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.77k stars 467 forks source link

perf: memoize encodeChange #480

Open nornagon opened 2 years ago

nornagon commented 2 years ago

This stores the original buffer from which a change was decoded, so that encodeChange(decodeChange(buf)) === buf. This saves a fairly significant amount of computation in computeHashGraph, in my test case bringing the time to compute the hash graph down from 4.5 sec to 3.5 sec.