Crate imara_diff
source · [−]Expand description
Imara-diff is a solid (imara in swahili) diff library for rust. Solid refers to the fact that imara-diff provides very good runtime performance even in pathologic cases so that your application never appears to freeze while waiting on a diff. The performance improvements are achieved using battle tested heuristics used in gnu-diff and git that are known to yield fast runtime and performance.
Imara-diff is also designed to be flexible so that it can be used with arbitrary collections and not just lists and strings and even allows reusing large parts of the computation when comparing the same file to multiple different files.
Imara-diff provides two diff algorithms:
- The linear-space variant of the well known myer algorithm
- The histogram algorithm which variant of the patience diff algorithm.
Myers algorithm has been enhanced with preprocessing and multiple heuristics to ensure fast runtime in pathological cases to avoid quadratic time complexity and closely matches the behaviour of gnu-diff and git. The histogram algorithm was originally ported from git but has been heavily optimized. The histogram algorithm outperforms myers diff by 10% - 100% across a wide variety of workloads.
Imara-diffs algorithms have been benchmarked over a wide variety of real-world code.
For example while comparing multiple different linux kernel it performs up to 30 times better than the similar
crate:
Re-exports
pub use crate::sink::Sink;
Modules
Structs
Sink
that creates a textual diff
in the format typically output by git or gnu-diff if the -u
option is usedEnums
imara-diff
supports multiple different algorithms
for computing an edit sequence.
These algorithms have different performance and all produce different output.Functions
input.before
into input.after
using
the specified algorithm
The edit-script is passed to sink.process_change
while it is produced.before
into after
using
the specified algorithm
The edit-script is passed to sink.process_change
while it is produced.