-
Notifications
You must be signed in to change notification settings - Fork 600
Rework hashing in C++ #2123
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
Rework hashing in C++ #2123
Conversation
{ | ||
int value = Reference::hashInit(); | ||
hashAdd(value, _adapterId); |
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.
In a remarkable twist, we were not including endpoints at all in the hash. As a result, all the endpoint hashing was completely unused!
I double checked - this code is identical on 3.7.
} | ||
|
||
inline void hashAdd(std::int32_t& hashCode, const std::string& value) | ||
inline void hashAdd(std::size_t& hashCode, const std::vector<EndpointIPtr>& seq) | ||
{ |
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.
We could add the container's size to the hash, when hashing a collection.
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.
I'd rather keep the same logic as in C#.
In C#, since we treat null collection = empty collection, and we skip nulls, we can't add the size of the collection to the hash.
This PR reworks the hashing in C++.
The only public hashing in C++ is for proxies. It is now exposed as a std::hash specialization of Ice::ObjectPrx.
It's used primarily by the C++-based language mappings: Python and Ruby. Strangely, it does not appear to be used by PHP.