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,
)
| 103 | /// otherwise it starts over. The closures aligned least recently are |
| 104 | /// dropped beyond `CLOSURE_CAPACITY`. |
| 105 | pub(super) fn align( |
| 106 | &mut self, |
| 107 | view: &str, |
| 108 | excluded: &[Hash], |
| 109 | visibility: &GraphVisibilityClosure, |
| 110 | ) { |
| 111 | let key = MemoKey::new(view, excluded); |
| 112 | let retained = self |
| 113 | .closures |
| 114 | .iter() |
| 115 | .position(|closure| closure.key == key) |
| 116 | .map(|index| self.closures.remove(index)); |
| 117 | let current = match retained { |
| 118 | Some(closure) if closure.describes(visibility) => closure, |
| 119 | _ => FoldedClosure::new(key), |
| 120 | }; |
| 121 | self.closures.insert(0, current); |
| 122 | self.closures.truncate(CLOSURE_CAPACITY); |
| 123 | } |
| 124 | |
| 125 | pub(super) fn is_folded(&self, change_id: NodeId) -> bool { |
| 126 | self.closures |