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

Avoid holding copies of all lines of b in the internal b2j map #4

Merged
merged 2 commits into from
Nov 3, 2019

Conversation

FrnchFrgg
Copy link

This is done by using sha1 hashes of the lines as keys. Of course due to (very rare) potential collisions, one hash gives a list of |indices| slices instead of directly the one we want, but we can chose the correct one by comparing the line passed with b[indices[0]].

Julien "_FrnchFrgg_" RIVAUD added 2 commits November 3, 2019 13:47
So that it can be improved later.
This way it should avoid a lot of allocations.
@FrnchFrgg
Copy link
Author

Note that this paves the way for a change of API to use []bytes, which cannot be used as map keys, but can be hashed by sha1.New() hasher just by replacing NewBufferString with NewBuffer.

@FrnchFrgg
Copy link
Author

(The API change I could write, but then I don't know how you want to preserve compatibility with previous releases)

@ianbruene ianbruene merged commit 5e5c896 into ianbruene:master Nov 3, 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