Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Switch
std::string
-> hashes for label resolution. #2215Switch
std::string
-> hashes for label resolution. #2215Changes from 11 commits
c8421fd
d13a5b1
ee037fc
f008f72
eb2c7fb
d8546fc
cf2a5f8
682a6aa
fbdf107
ef792c9
97ca7a4
0cec44f
c583b2f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think this is not needed.
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.
Oh dear my old vice ;)
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.
Thanks for moving it here!
I just have one suggestion.
Calling
internal_hash
andhash_value
would give different results for a single type due to the multiplication with the prime number inhash_value_combine
. How about merging theinternal_hash
function intohash_value
?So something like this:
This way we would simply always use
hash_value
throughout the code.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.
Also, a comment mentioning the different behaviour for
char*
andconst char*
types would be good. For these, the content they point to is hashed. Any other type of pointer will have the hash of the pointer value itself.Or we do not allow usage with other types of pointers.
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.
Ok. I decided to add a slightly more intricate logic layer:
Idea being that hashes of pointer types are likely be unintended and must be opted-in to via casting to void*.
The deviation from STL is meant to spread out integer-keyed maps a bit better. I hope they do not use a similar
scheme for real values...
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 think this is a decent solution for the problem of how to treat different pointer types.
The first comment is not yet addressed however. Calling
hash_value
andinternal_hash
for a single type will yield a different hash. As suggested above, we could just overload thehash_value
function, such that the currentinternal_hash
function will just become thehash_value
function for single types. This way we can also get rid ofhash_value_combine
, which appears to be only used here.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.
Ok, I changed the
hash_combine
function (below) s.t.shouldn't that address your comment?
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.
Yeah, I missed that change. I think just having
hash_value
would still be overall cleaner theninternal_hash
,hash_combine
andhash_value
. But from a functionality point of view I'm ok with it as is.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.
Well, the surface now just is
hash_value
. I should adjust the usage accordingly and stuffinternal_hash
andhash_combine
into adetail
namespace.