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

Function changed

atomic-audit/src/extract/tokens.rs:108–134  ·  view source on GitHub ↗
(
    old: &[Token],
    new: &[Token],
    work: &mut usize,
)

Source from the content-addressed store, hash-verified

106}
107
108pub(super) fn changed(
109 old: &[Token],
110 new: &[Token],
111 work: &mut usize,
112) -> Result<(Vec<bool>, Vec<bool>), String> {
113 if old == new {
114 return Ok((vec![false; old.len()], vec![false; new.len()]));
115 }
116 let cost = old.len().saturating_mul(new.len());
117 if cost > *work {
118 return Err("Changed-token diff work budget exceeded".into());
119 }
120 *work -= cost;
121 let mut before = vec![false; old.len()];
122 let mut after = vec![false; new.len()];
123 for op in similar::capture_diff_slices(similar::Algorithm::Myers, old, new) {
124 if op.tag() != similar::DiffTag::Equal {
125 for index in op.old_range() {
126 before[index] = true;
127 }
128 for index in op.new_range() {
129 after[index] = true;
130 }
131 }
132 }
133 Ok((before, after))
134}
135
136/// Exact same-language token windows. Verify equality after hashing; collisions
137/// never become clone evidence. Overlaps are unioned and never counted twice.

Callers 1

extract_changesFunction · 0.70

Calls 4

lenMethod · 0.45
tagMethod · 0.45
old_rangeMethod · 0.45
new_rangeMethod · 0.45

Tested by

no test coverage detected