MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / align

Method align

atomic-repository/src/repository/semantic_closure.rs:96–114  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 6

describesMethod · 0.80
truncateMethod · 0.80
removeMethod · 0.65
positionMethod · 0.45
iterMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected