Skip to main content

simplify_changes

Function simplify_changes 

Source
pub fn simplify_changes(changes: Vec<(Link, Link)>) -> Vec<(Link, Link)>
Expand description

Reduces the raw (before, after) steps a store reports to one change per link address: from its state before the query to its state after it.

The store reports every step it takes — a link is emptied to (i: 0 0) before it is deleted and created as (i: 0 0) before it is set — and the null link (0: 0 0) stands for “no link”, before a creation and after a deletion. The steps of one address form a chain, so its net change is the before of its first step and the after of its last:

  • a link created and deleted again within the query is not reported;
  • a link that ends where it started is reported unchanged, like a link the query only matched.

The changes are ordered by their after state, so deletions come first; changes with equal after states keep the order of their first step.