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

Hash faster by not using derive #775

Open
jrose-signal opened this issue Dec 12, 2024 · 2 comments
Open

Hash faster by not using derive #775

jrose-signal opened this issue Dec 12, 2024 · 2 comments

Comments

@jrose-signal
Copy link
Contributor

Uuid currently uses derive(Hash), but this calls through to an array's default implementation, which in turn calls to the implementation for slices, which includes a length prefix and goes element by element. Instead, it could just call state.write(&self.0) directly.

@KodrAus
Copy link
Member

KodrAus commented Dec 13, 2024

The Hash trait doesn’t guarantee stability of hashes unless you have control over both the hasher and type being hashed, so I think we should be able to make this change.

It’s technically unrelated, but what we can’t unfortunately do is change how we compute hashes in v1, v3, or v5 UUIDs, or else we’d start computing a different UUID for the same input.

@jrose-signal
Copy link
Contributor Author

That's fine, those already pass the bytes directly. (And they are fully specified by the UUID standard, so they're either correct or wrong as they are.)

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

No branches or pull requests

3 participants
@KodrAus @jrose-signal and others