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

Method align

atomic-repository/src/repository/semantic_closure.rs:105–123  ·  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

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

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