libmdnsd: Make SPRIME actually a prime number #65
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.
Hashing strings for hash tables usually involves a prime number. It breaks down the raw hash into one bucket and therefore defines the size of the hash table. Chosing a prime number as hash table size will greatly reduce the number of collisions.
mdnsd uses two hash table sizes, defined by
LPRIME
andSPRIME
. WhileLPRIME
is defined to 1009, which is a prime number,SPRIME
is defined to 108 - obviously not a prime number. Since I could not find any reason for this in code or history, this commit sets the value ofSPRIME
to 109 so that it actually is a prime number. Since using prime numbers just makes sense for hash table sizes.