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

Function covers

atomic-core/src/pristine/span_patch_storage/legacy.rs:33–66  ·  view source on GitHub ↗
(state: &SpanRecordState, target: &ExternalSpan, start: u64, end: u64)

Source from the content-addressed store, hash-verified

31}
32
33pub(super) fn covers(state: &SpanRecordState, target: &ExternalSpan, start: u64, end: u64) -> bool {
34 if target == &state.root && target.start == target.end {
35 return state.content.is_empty() && start == 0 && end == 0;
36 }
37 let mut ranges = state
38 .spans
39 .iter()
40 .filter(|span| &span.target == target)
41 .map(|span| {
42 (
43 span.target_start,
44 span.target_start + span.output.len() as u64,
45 )
46 })
47 .collect::<Vec<_>>();
48 ranges.sort();
49 let mut at = start;
50 for (lo, hi) in ranges {
51 if start == end && lo <= start && start <= hi {
52 return true;
53 }
54 if hi <= at {
55 continue;
56 }
57 if lo > at {
58 return false;
59 }
60 at = hi;
61 if at >= end {
62 return true;
63 }
64 }
65 false
66}
67
68pub(super) fn metadata(hash: Hash, change: &Change) -> LegacyMetadata {
69 let mut result = LegacyMetadata::default();

Callers

nothing calls this directly

Calls 4

sortMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected