Hash faster by not using derive #775
Labels
No labels
breaking
bug
dependencies
good first issue
help wanted
unstable
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-uuid-rs/uuid#775
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 callstate.write(&self.0)directly.The
Hashtrait 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.
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.)