pub struct Dmp {
pub diff_timeout: Option<f32>,
pub edit_cost: i32,
pub match_distance: i32,
pub patch_margin: i32,
pub match_maxbits: i32,
pub match_threshold: f32,
pub patch_delete_threshold: f32,
}Fields§
§diff_timeout: Option<f32>Number of seconds to map a diff before giving up (None for infinity).
edit_cost: i32Cost of an empty edit operation in terms of edit characters.
match_distance: i32How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match).
patch_margin: i32Chunk size for context length.
match_maxbits: i32The number of bits in an int. Python has no maximum, thus to disable patch splitting set to 0. However to avoid long patches in certain pathological cases, use 32. Multiple short patches (using native ints) are much faster than long ones.
match_threshold: f32At what point is no match declared (0.0 = perfection, 1.0 = very loose).
patch_delete_threshold: f32When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that match_threshold controls how closely the end points of a delete need to match.
Implementations§
Source§impl Dmp
impl Dmp
Sourcepub fn diff_main(&self, text1: &str, text2: &str, checklines: bool) -> Vec<Diff>
pub fn diff_main(&self, text1: &str, text2: &str, checklines: bool) -> Vec<Diff>
Find the differences between two chars. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing.
§Args
- text1: Old chars to be diffed.
- text2: New chars to be diffed.
- checklines: Optional speedup flag. If present and false, then don’t run a line-level diff first to identify the changed areas. Defaults to true, which does a faster, slightly less optimal diff.
§Return
Vector of diffs as changes.
Sourcepub fn diff_chars_tolines(&self, diffs: &mut Vec<Diff>, line_array: &[String])
pub fn diff_chars_tolines(&self, diffs: &mut Vec<Diff>, line_array: &[String])
Rehydrate the text in a diff from a string of line hashes to real lines of text.
Args
- diffs: Vector of diffs as changes.
- lineArray: Vector of unique strings.
Sourcepub fn diff_cleanup_semantic(&self, diffs: &mut Vec<Diff>)
pub fn diff_cleanup_semantic(&self, diffs: &mut Vec<Diff>)
Reduce the number of edits by eliminating semantically trivial equalities.
§Args
- diffs: Vectors of diff object.
Sourcepub fn diff_cleanup_semantic_lossless(&self, diffs: &mut Vec<Diff>)
pub fn diff_cleanup_semantic_lossless(&self, diffs: &mut Vec<Diff>)
Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. e.g: The cat came. -> The cat came.
Args:
- diffs: Vector of diff object.
Sourcepub fn diff_cleanup_efficiency(&self, diffs: &mut Vec<Diff>)
pub fn diff_cleanup_efficiency(&self, diffs: &mut Vec<Diff>)
Reduce the number of edits by eliminating operationally trivial equalities.
§Args
- diffs: Vector of diff object.
Sourcepub fn diff_cleanup_merge(&self, diffs: &mut Vec<Diff>)
pub fn diff_cleanup_merge(&self, diffs: &mut Vec<Diff>)
Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn’t cross an equality.
§Args
- diffs: vectors of diff object.