fix: remove unnecessary hash calculations #8

Closed
jrandolf wants to merge 1 commit from patch-1 into master
jrandolf commented 2021-03-19 00:12:57 +01:00 (Migrated from github.com)
No description provided.
marijnh commented 2021-03-19 07:53:44 +01:00 (Migrated from github.com)

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.

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 commented 2021-03-19 09:53:38 +01:00 (Migrated from github.com)

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.

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 commented 2021-03-19 10:31:00 +01:00 (Migrated from github.com)

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.

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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/python!8
No description provided.