Remove unneeded loop in SpliceMutator::mutate (#1471)

previously we searched for the first and the last difference
between exactly the same 2 inputs 3 times in a loop

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
This commit is contained in:
lenawanel 2023-08-29 13:30:29 +02:00 committed by GitHub
parent 7d2c854b71
commit f3a4f4f664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1282,17 +1282,12 @@ where
let mut other_testcase = state.corpus().get(idx)?.borrow_mut(); let mut other_testcase = state.corpus().get(idx)?.borrow_mut();
let other = other_testcase.load_input(state.corpus())?; let other = other_testcase.load_input(state.corpus())?;
let mut counter: u32 = 0; let (f, l) = locate_diffs(input.bytes(), other.bytes());
loop {
let (f, l) = locate_diffs(input.bytes(), other.bytes());
if f != l && f >= 0 && l >= 2 { if f != l && f >= 0 && l >= 2 {
break (f as u64, l as u64); (f as u64, l as u64)
} } else {
if counter == 3 { return Ok(MutationResult::Skipped);
return Ok(MutationResult::Skipped);
}
counter += 1;
} }
}; };