3 ms·
Am I missing something or would it just need to be a doubly linked list? It really depends on your program state being… stateful (so you can navigate forwards a
by MaxLeiter 4y ago
Am I missing something or would it just need to be a doubly linked list? It really depends on your program state being… stateful (so you can navigate forwards and back consistently)
- blt 4y agoIf you store the total application state for each step then it's simple, but consumes lots of memory. If you want to store something more like a diff, there are choices. For example, you could have code to undo each operation, but you can also implement undo by going back to some checkpoint and then recomputing all operations between the checkpoint and now. Latter consumes more CPU, but comparable memory and a lot less code surface for bugs.
- neilparikh 4y agoIf you use persistent data structures, you can store the total state, and you'll get deduplication of the common parts, which brings down the memory usage to a more reasonable amount. This is what git does essentially, which gets you O(1) checkout to arbitrary steps in the future/past. This also means you don't need to design/pick a diffing algorithm, which you would be locked into (since changing the diffing algorithm would mean you couldn't consume old diffs).
- account42 4y agoGit does store deltas when packing objects because storing all distinct objects as-is would be too inefficient for large repos. This isn't the same text diffs as shown to the user but there is still a diffing algorithm that all future git versions need to support (well, at least the patch counterpart).