Skip to content

Fast Levenshtein diff, as fast as we can do with levenshtein

License

Notifications You must be signed in to change notification settings

adrien-zinger/liff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Liff 🍃 cargo version CI

Compute the diff between two vectors with the Levenshtein algorithm.

Faster than other crate. Try cargo bench to see the difference.

Usage

Levenshtein is a O(n1n2) time complexty and in space so you don't want to use it with a big raw. But you can use it with good chunks or text content!

    let from: Vec<u8> = input_text_from.as_bytes().into();
    let to: Vec<u8> = input_text_to.as_bytes().into();
    let diff = diff::diff::<u8>(&from, &to);

Use the diff output

The diff output can be used as a patch from another part of your code.

    let res = apply::apply(from, &diff);
    // res should be equals to "to"

Write temporary a compressed patch

the diff patch is quite bigger than we can do. You can compress it and that's what we do when we dump a file. You can read and write a diff with these functions.

    diffio::write(std::path::Path::new("diff.d"), diff.clone());
    let diff = diffio::read(std::path::Path::new("diff.d"));

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Fast Levenshtein diff, as fast as we can do with levenshtein

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published