Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up findLongestMatch by avoiding a lot of allocations #8

Merged
merged 3 commits into from
Nov 18, 2019

Conversation

FrnchFrgg
Copy link

Instead of using maps that are recreated anew at each iteration of the loop, allocate two slices once and reuse the old one after cleaning it up. This allocates 35% less and uses 27% less time on real-world cases, and on synthetic benchmarks with long files to diff and a bigger number of similar lines one can observe one tenth the allocations and half the running time.
This patch series contain improvements to both the []strings and [][]byte implementations.

@FrnchFrgg FrnchFrgg force-pushed the master branch 2 times, most recently from 1ac91c4 to f7750a7 Compare November 13, 2019 12:38
@ianbruene ianbruene merged commit 3189546 into ianbruene:master Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants