Skip to content

Make sure that the hash of referenced specialize types is the same#213

Merged
tkaitchuck merged 1 commit intotkaitchuck:masterfrom
eaufavor:specialize_reference_hash
Mar 1, 2024
Merged

Make sure that the hash of referenced specialize types is the same#213
tkaitchuck merged 1 commit intotkaitchuck:masterfrom
eaufavor:specialize_reference_hash

Conversation

@eaufavor
Copy link
Contributor

@eaufavor eaufavor commented Feb 28, 2024

In general users would expect the hash of &T is the same as the hash of T. This is the case in ahash unless the "specialize" feature is used.

This change is a stop gap to make sure that the hash of the specialized types is the same whether reference is used or not.

Note that this change still doesn't address doubly referenced types like &&u64. But hopefully it already covers most cases.

Fixes #214

In general users would expect the hash of &T is the same as the hash of
T. This is the case in ahash unless the "specialize" feature is used.

This change is a stop gap to make sure that the hash of the specialized
types is the same whether reference is used or not.

Note that this change still doesn't address doubly referenced types
like &&u64. But hopefully it already covers most cases.
@tkaitchuck
Copy link
Owner

I am aware of this limitation, and am planning to resolve it in a more permanent way by having the hasher rather then the method typed to the item being hashed. This is obviously a API breaking change, so it will need to be a major release.

@tkaitchuck
Copy link
Owner

This is fine as a temporary measure, but it should probably also cover &&str and &String.

@tkaitchuck tkaitchuck self-requested a review February 29, 2024 19:25
@tkaitchuck tkaitchuck merged commit e7481cd into tkaitchuck:master Mar 1, 2024
tkaitchuck added a commit that referenced this pull request Mar 2, 2024
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
tkaitchuck added a commit that referenced this pull request Mar 3, 2024
* Make RandomState typed to the type to be hashed
* Add test from #213
* All smhasher tests pass

Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
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.

Hashing &T yields different results compared to T

2 participants