Repository navigation
Conversation
- Remove external `diff` crate dependency from Cargo.toml and Cargo.lock - Update context, ed, normal, side, and unified diff implementations to use the new internal engine
| itoa = "1.0.11" | ||
| regex = "1.10.4" | ||
| same-file = "1.0.6" | ||
| similar = { version = "3.2.1", default-features = false, features = ["std"] } |
There was a problem hiding this comment.
why is bstr pulled into Cargo.lock?
we only enable std, and in similar it is bstr?/std, so it shouldn't be activated
| diff(from_file, to_file, &mut output, ¶ms); | ||
|
|
||
| assert_eq!(output, vec![]); | ||
| assert_eq!(output, Vec::<u8>::new()); |
There was a problem hiding this comment.
why is this change needed? looks like a side effect of bstr being compiled in
| new_index, | ||
| new_len, | ||
| } => { | ||
| for i in 0..old_len { |
There was a problem hiding this comment.
almost the same loop 4 times
could be changes.extend(expected[old_index..old_index + old_len].iter().map(Change::Left)), no?
| actual: &'a [T], | ||
| ) -> Vec<Change<&'a T>> { | ||
| let ops = capture_diff_slices(Algorithm::Myers, expected, actual); | ||
| let mut changes = Vec::new(); |
There was a problem hiding this comment.
Vec::with_capacity(expected.len() + actual.len())?
|
|
||
| #[test] | ||
| fn test_insertions_and_deletions() { | ||
| let a: &[&[u8]] = &[b"line1", b"line2", b"line3"]; |
There was a problem hiding this comment.
please add a test where Myers and the old LCS output differ, so we know the hunks we now produce
and one with a larger input
|
thanks for the work on this! |
fix: disable std feature for similar dependency and fix the Cargo.lock file diff_engine: replace manual loops with idiomatic rust (iterators) diff_engine: preallocate vector test(diff): add more unit and integration tests for diff engine
|
Thanks for the review! |
Merging this PR will degrade performance by 10.83%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
|
The regressed Something else I wanted to point out is that I need a bit more research before implementing next steps, thanks |
|
Oops, I meant to just comment, accidently pressed some shortcut and closed the PR, sorry 😅 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #415 +/- ##
===========================
===========================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Replaces the external
diffcrate dependency with an internaldiff_enginemodule wrapping the modernsimilarcrate. All diff consumers (context_diff,ed_diff,normal_diff,side_diff, andunified_diff) have been refactored to utilize the new internal engine and itsChangeenum types.Resolves: #401
Key Changes
diff_enginemodule wrappingsimilar(version3.2.1) using Eugene Myers' linear-space algorithm.Changeenum (Left,Right,Both) mirroring the sequence comparison outputs.diff = "0.1.13"external dependency fromCargo.toml.context_diff,ed_diff,normal_diff,side_diff, andunified_diffto consumediff_slicesandChangefromdiff_engine.src/diff_engine.rs.Performance benchmarks
541KB(10k lines) file with sparse differences./old_diff bench_data/med_sparse_a.txt bench_data/med_sparse_b.txt./new_diff bench_data/med_sparse_a.txt bench_data/med_sparse_b.txt2.7MB(50k lines) file with sparse differences./old_diff bench_data/large_sparse_a.txt bench_data/large_sparse_b.txt./new_diff bench_data/large_sparse_a.txt bench_data/large_sparse_b.txtBenchmark against
GNU diffusing the 2.7MB filediff bench_data/large_sparse_a.txt bench_data/large_sparse_b.txt./new_diff bench_data/large_sparse_a.txt bench_data/large_sparse_b.txtTested on: Macbook Air M2