Find the longest match in the suffix-sorted array #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2
The current implementation performs a binary search through the suffix-sorted array to find byte sequence matches between old and new files. However, the algorithm is not optimal when it repeatedly matches very short strings, leading to performance issues as reported in issue #2 .
This commit changes the algorithm to consider all matches encountered during the binary search and choose the longest of these matches.
The overall performance impact is yet to be determined, but it appears to yield a small percentage increase in diff creation time (expected) and a large percentage decrease for the case of diffing the files from issue #2. In my testing, the creation time there decreases from approx 64 minutes to 4.5 seconds.