-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Added .hash() functions for vectors #2043
base: master
Are you sure you want to change the base?
Conversation
This looks wrong. You're hashing the vectors on their pointer, not on their content. |
…slice, the same approch is used for arrays
It should be fixed now. I also added support for arrays of all the normal types. |
For the tests you want to create two vectors separately but with the same values and check that they give the same hash. |
I did do that in a test program I wrote, but since the normal hash functions did not do this I hadn't added it to the test yet. |
macro uint uint128.hash(uint128 i) => @generic_hash(i); | ||
macro uint uint128[<*>].hash(uint128[<*>] i) => (uint)fnv32a::hash(((char*)&&i)[:$sizeof(i[0])*i.len]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add space between operators to keep the code consistent, e.g. $sizeof(i[0]) * i.len
If you take the address of char/ichar arrays / vectors they can be cast to a |
Currently only vectors up to 16 bytes in size can be used in a Hashmap due to the requirement of
$Type.alignof <= mem::DEFAULT_MEM_ALIGNMENT
onallocator:new
I recon allowing for larger types would require changes to the Hashmap module.
Suggestions on how to improve the functionalities are welcome.