Expand description
Element ids kept across edits: a file’s new parse matched against its
last, sibling list by sibling list, so an element keeps its id however
the lines around it change. Siblings with a key are matched by it; the
others by a shortest edit script over the list (Myers’ diff), comparing
each element whole — its name, its own attributes and everything in it —
and then, among what is left between two matches, an element with one of
the same name, in order, as an edit of it. A matched element’s children
are matched the same way; an element left over is new and takes the
file’s next id.
The cost is a pass over the file: lists are trimmed of what they share at
either end, and Myers’ diff, which costs a list’s length times its edits,
is searched to MAX_EDITS edits. Past that — a save that rewrote the
list — the list is matched by a histogram diff: every element that occurs
once on each side is matched wherever it now is, the longest run of them
in order splits the list into gaps, and each gap is matched again the same
way. That is near-linear however many edits there are, and never pairs
the list by position.
A store that keeps designs between saves reads its files through
Remembering, which keeps each design file’s last parse and matches
the next against it.
Structs§
- Parses
- Each design file’s last parse, by path. A clone shares them: a store keeps one and reads through it with whichever files each resolve uses.
- Remembering
files, with each design file parsed matched against its last parse inParses— and remembered there as its last.
Constants§
- MAX_
EDITS - The longest edit script searched for between two lists of siblings.