cargo format
This commit is contained in:
parent
fdecdbc6c9
commit
332ca5582b
6 changed files with 67 additions and 30 deletions
|
|
@ -320,5 +320,7 @@ pub fn diff_fp_f64_deadline<D>(
|
|||
where
|
||||
D: DiffHook,
|
||||
{
|
||||
crate::algorithms::myers::diff_fp_f64_deadline(d, old, old_range, new, new_range, epsilon, deadline)
|
||||
crate::algorithms::myers::diff_fp_f64_deadline(
|
||||
d, old, old_range, new, new_range, epsilon, deadline,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,4 +132,3 @@ where
|
|||
{
|
||||
diff_deadline(alg, d, old, 0..old.len(), new, 0..new.len(), deadline)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@
|
|||
|
||||
use std::ops::{Index, IndexMut, Range};
|
||||
|
||||
use crate::algorithms::utils::{common_prefix_len, common_suffix_len, common_prefix_len_fp, common_suffix_len_fp, common_prefix_len_fp_f64, common_suffix_len_fp_f64, is_empty_range};
|
||||
use crate::algorithms::utils::{
|
||||
common_prefix_len, common_prefix_len_fp, common_prefix_len_fp_f64, common_suffix_len,
|
||||
common_suffix_len_fp, common_suffix_len_fp_f64, is_empty_range,
|
||||
};
|
||||
use crate::algorithms::DiffHook;
|
||||
use crate::deadline_support::{deadline_exceeded, Instant};
|
||||
|
||||
|
|
@ -457,7 +460,9 @@ where
|
|||
let max_d = max_d(old_range.len(), new_range.len());
|
||||
let mut vb = V::new(max_d);
|
||||
let mut vf = V::new(max_d);
|
||||
conquer_fp(d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline)?;
|
||||
conquer_fp(
|
||||
d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline,
|
||||
)?;
|
||||
d.finish()
|
||||
}
|
||||
|
||||
|
|
@ -477,7 +482,9 @@ where
|
|||
let max_d = max_d(old_range.len(), new_range.len());
|
||||
let mut vb = V::new(max_d);
|
||||
let mut vf = V::new(max_d);
|
||||
conquer_fp_f64(d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline)?;
|
||||
conquer_fp_f64(
|
||||
d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline,
|
||||
)?;
|
||||
d.finish()
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +688,8 @@ where
|
|||
D: DiffHook,
|
||||
{
|
||||
// Check for common prefix
|
||||
let common_prefix_len = common_prefix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_prefix_len =
|
||||
common_prefix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
if common_prefix_len > 0 {
|
||||
d.equal(old_range.start, new_range.start, common_prefix_len)?;
|
||||
}
|
||||
|
|
@ -689,7 +697,8 @@ where
|
|||
new_range.start += common_prefix_len;
|
||||
|
||||
// Check for common suffix
|
||||
let common_suffix_len = common_suffix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_suffix_len =
|
||||
common_suffix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_suffix = (
|
||||
old_range.end - common_suffix_len,
|
||||
new_range.end - common_suffix_len,
|
||||
|
|
@ -753,7 +762,8 @@ where
|
|||
D: DiffHook,
|
||||
{
|
||||
// Check for common prefix
|
||||
let common_prefix_len = common_prefix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_prefix_len =
|
||||
common_prefix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
if common_prefix_len > 0 {
|
||||
d.equal(old_range.start, new_range.start, common_prefix_len)?;
|
||||
}
|
||||
|
|
@ -761,7 +771,8 @@ where
|
|||
new_range.start += common_prefix_len;
|
||||
|
||||
// Check for common suffix
|
||||
let common_suffix_len = common_suffix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_suffix_len =
|
||||
common_suffix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon);
|
||||
let common_suffix = (
|
||||
old_range.end - common_suffix_len,
|
||||
new_range.end - common_suffix_len,
|
||||
|
|
|
|||
|
|
@ -224,5 +224,7 @@ pub fn diff_fp_f64_deadline<D>(
|
|||
where
|
||||
D: DiffHook,
|
||||
{
|
||||
crate::algorithms::myers::diff_fp_f64_deadline(d, old, old_range, new, new_range, epsilon, deadline)
|
||||
crate::algorithms::myers::diff_fp_f64_deadline(
|
||||
d, old, old_range, new, new_range, epsilon, deadline,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,9 +124,15 @@ fn capture_diff_fp_deadline(
|
|||
) -> Vec<DiffOp> {
|
||||
let mut d = Compact::new(Replace::new(Capture::new()), old, new);
|
||||
let result = match alg {
|
||||
Algorithm::Myers => crate::algorithms::myers::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Patience => crate::algorithms::patience::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Lcs => crate::algorithms::lcs::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Myers => crate::algorithms::myers::diff_fp_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
Algorithm::Patience => crate::algorithms::patience::diff_fp_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
Algorithm::Lcs => crate::algorithms::lcs::diff_fp_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
};
|
||||
result.unwrap();
|
||||
d.into_inner().into_inner().into_ops()
|
||||
|
|
@ -143,9 +149,15 @@ fn capture_diff_fp_f64_deadline(
|
|||
) -> Vec<DiffOp> {
|
||||
let mut d = Compact::new(Replace::new(Capture::new()), old, new);
|
||||
let result = match alg {
|
||||
Algorithm::Myers => crate::algorithms::myers::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Patience => crate::algorithms::patience::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Lcs => crate::algorithms::lcs::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline),
|
||||
Algorithm::Myers => crate::algorithms::myers::diff_fp_f64_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
Algorithm::Patience => crate::algorithms::patience::diff_fp_f64_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
Algorithm::Lcs => crate::algorithms::lcs::diff_fp_f64_deadline(
|
||||
&mut d, old, old_range, new, new_range, epsilon, deadline,
|
||||
),
|
||||
};
|
||||
result.unwrap();
|
||||
d.into_inner().into_inner().into_ops()
|
||||
|
|
@ -268,10 +280,10 @@ fn test_non_string_iter_change() {
|
|||
fn test_fp_epsilon() {
|
||||
let old = vec![1.0, 2.0, 3.0];
|
||||
let new = vec![1.001, 2.0, 2.999];
|
||||
|
||||
|
||||
let ops_tight = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.0001);
|
||||
assert!(ops_tight.len() > 1);
|
||||
|
||||
|
||||
let ops_loose = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.01);
|
||||
assert_eq!(ops_loose.len(), 1);
|
||||
}
|
||||
|
|
@ -280,9 +292,7 @@ fn test_fp_epsilon() {
|
|||
fn test_fp_nan() {
|
||||
let old = vec![f32::NAN];
|
||||
let new = vec![f32::NAN];
|
||||
|
||||
|
||||
let ops = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.001);
|
||||
assert_eq!(ops.len(), 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue