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

Function block

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

`find_block` query against a loaded span set. Spans within a change do not overlap, so the candidate containing `target` is the greatest-start non-empty span with `start <= target`; if its range doesn't contain `target`, no non-empty span does. Falls back to an empty marker at exactly `target`.

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

Source from the content-addressed store, hash-verified

61/// doesn't contain `target`, no non-empty span does. Falls back to an empty
62/// marker at exactly `target`.
63fn block(set: &BTreeSet<(u64, u64)>, target: u64) -> Option<(u64, u64)> {
64 for &(s, e) in set.range(..=(target, u64::MAX)).rev() {
65 if s == e {
66 continue;
67 }
68 if s <= target && target < e {
69 return Some((s, e));
70 }
71 break;
72 }
73 if set.contains(&(target, target)) {
74 return Some((target, target));
75 }
76 None
77}
78
79/// `find_block_end` query against a loaded span set.
80///

Callers 1

find_blockMethod · 0.85

Calls 2

rangeMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected