Skip to content
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

fix: remove unnecessary hash calculations #8

Closed
wants to merge 1 commit into from
Closed

fix: remove unnecessary hash calculations #8

wants to merge 1 commit into from

Conversation

jrandolf
Copy link

No description provided.

@marijnh
Copy link
Contributor

marijnh commented Mar 19, 2021

What's the reasoning behind this change? The extra shift and add won't actually be expensive, and I've often seen this pattern (with a bitshift on both values) in simple hash functions.

@jrandolf
Copy link
Author

jrandolf commented Mar 19, 2021

I don't see the reason why both values are bit shifted. The depth is already bit shifted (<< 0) and the parent just bit shifts to allocate for the maximal depth (in this case, 2^8).

[Edit]: We also need to modulo the parent hash with some prime to truncate for later, but this hash holds for at least 16 or so indents without overflowing.

@marijnh
Copy link
Contributor

marijnh commented Mar 19, 2021

I don't know a lot about hash functions, but running a simulation on hashing groups of small integers this change increases the amounts of clashes by about 30%, so I don't think it's a good idea.

@marijnh marijnh closed this Mar 19, 2021
@jrandolf jrandolf deleted the patch-1 branch March 19, 2021 09:56
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.

2 participants