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’s name and own attributes, 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 an edit script longer than MAX_EDITS gives way to
matching the rest in order, so no list costs more than its length times
that.
Constants§
- MAX_
EDITS - The longest edit script searched for between two lists of siblings.