-
Notifications
You must be signed in to change notification settings - Fork 98
Improve float/double hash values #124
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
Conversation
Right now the hash value for floats is their integer component. Instead, use dark magic to map the bits to an int.
| } hack; | ||
|
|
||
| hack.d = Z_DVAL_P(value); | ||
| return (uint32_t)(hack.ull ^ (hack.ull >> 32)); |
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.
Not sure how exactly ds defines floating point equality for the purpose of HT lookups, but most likely 0. === -0., which would not be handled correctly by this hash.
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.
Good catch - 0.0 and -0.0 are mapped to the same value on master.
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.
@nikic === is used.
|
Looks good, if this passes we can merge. ✨ |
|
(Closing and re-opening to bump Travis) |
|
Hah I restarted the build on Travis as well 😂 |
|
Well this obviously isn't right. |
|
I'll merge this now and sort the test suite out tomorrow. |
Right now the hash value for floats is their integer component. Instead, use dark magic to map the bits to an int.
Simple test script:
Time before patch: 16.721446990967
Time with patch: 0.012161016464233