Make the closure of `view` under `excluded` the current one: its folded prefix is kept when every folded change is still visible, otherwise it starts over. The closures aligned least recently are dropped beyond `CLOSURE_CAPACITY`.
(
&mut self,
view: &str,
excluded: &[Hash],
visibility: &GraphVisibilityClosure,
)
| 94 | /// otherwise it starts over. The closures aligned least recently are |
| 95 | /// dropped beyond `CLOSURE_CAPACITY`. |
| 96 | pub(super) fn align( |
| 97 | &mut self, |
| 98 | view: &str, |
| 99 | excluded: &[Hash], |
| 100 | visibility: &GraphVisibilityClosure, |
| 101 | ) { |
| 102 | let key = MemoKey::new(view, excluded); |
| 103 | let retained = self |
| 104 | .closures |
| 105 | .iter() |
| 106 | .position(|closure| closure.key == key) |
| 107 | .map(|index| self.closures.remove(index)); |
| 108 | let current = match retained { |
| 109 | Some(closure) if closure.describes(visibility) => closure, |
| 110 | _ => FoldedClosure::new(key), |
| 111 | }; |
| 112 | self.closures.insert(0, current); |
| 113 | self.closures.truncate(CLOSURE_CAPACITY); |
| 114 | } |
| 115 | |
| 116 | pub(super) fn is_folded(&self, change_id: NodeId) -> bool { |
| 117 | self.closures |