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

Implement a []byte-base API in a "bytes" subpackage #6

Merged
merged 9 commits into from
Nov 6, 2019

Conversation

FrnchFrgg
Copy link

Even with a lot of improvements compared to the current master, it still uses around 1.5x the time of the string-based implementation and API, so put it in a bytes subpackage and restore the original v1.1.2 string implementation in the toplevel package.
When/if the []byte API improves enough (or an interface{}-based one), this decision might be revisited to make the string API a user of the bytes subpackage.

Julien "_FrnchFrgg_" RIVAUD added 9 commits November 5, 2019 15:03
This doesn't need to be so exact as to care for sha1 collisions.
encoding.binary does too much copies.
It should avoid even more allocations, and be faster too.
Also create a custom type for hash results for clarity and ease of
change if we need to update the hash.
Now that the bytes API is in its own subpackage, restore the string-only
implementation since it is still faster. If the bytes implementation can
be optimized further the string API can be made to wrap the bytes
implementation, at least partially.
@FrnchFrgg
Copy link
Author

It's not 1.5x but 1.3x the time in fact, and it roughly allocates the same amount of data. It wins in the map, but looses in the slices because []byte slices are almost 1.5x the size of []string.

@ianbruene ianbruene merged commit 7f0db69 into ianbruene:master Nov 6, 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