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

Function block_end

atomic-core/src/pristine/span_index.rs:85–104  ·  view source on GitHub ↗

`find_block_end` query against a loaded span set. Prefers an empty marker at exactly `target` (e.g. an inode marker `V[9:9]` over a name vertex `V[0:9]` that also ends at 9), then the non-empty span immediately left of `target` if it ends at or contains `target`, then a non-empty span starting exactly at `target`.

(set: &BTreeSet<(u64, u64)>, target: u64)

Source from the content-addressed store, hash-verified

83/// immediately left of `target` if it ends at or contains `target`, then a
84/// non-empty span starting exactly at `target`.
85fn block_end(set: &BTreeSet<(u64, u64)>, target: u64) -> Option<(u64, u64)> {
86 if set.contains(&(target, target)) {
87 return Some((target, target));
88 }
89 for &(s, e) in set.range(..(target, 0u64)).rev() {
90 if s == e {
91 continue;
92 }
93 if e == target || (s <= target && target < e) {
94 return Some((s, e));
95 }
96 break;
97 }
98 for &(s, e) in set.range((target, 0u64)..=(target, u64::MAX)) {
99 if s != e {
100 return Some((s, e));
101 }
102 }
103 None
104}

Callers 1

find_block_endMethod · 0.85

Calls 2

rangeMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected