mitsuhiko / similar

A high level diffing library for rust based on diffs
https://insta.rs/similar
Apache License 2.0
949 stars 31 forks source link

Support for specifying timeout for iter_inline_changes() #60

Closed andreasscherman closed 5 months ago

andreasscherman commented 5 months ago

Hi!

Thanks a lot for this crate. I've really enjoyed using it.

I had some issues with timings where I couldn't figure out why my loop was slower than the TextDiff::from_lines() call. Instrumentation led me to finding out the iter_inline_changes() have a static cap at 500ms. I think it would be good to be able to specify a deadline for this function too. An issue where this shows up is in the terminal-inline.rs example, where if you have a sufficiently large file and have a small timeout for the TextDiff::from_lines(), the loop afterwards can still add 500ms.

Let me know if you think it makes sense, and I'll try to put together a PR if I get the time.

Thanks!