commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allon Mureinik (JIRA)" <>
Subject [jira] [Commented] (LANG-804) Redundant check for zero in HashCodeBuilder ctor
Date Wed, 04 Sep 2013 06:34:53 GMT


Allon Mureinik commented on LANG-804:

There are two issues here:

The original issue - is there any point in explicitly checking (and documenting) for zero?
Probably not, as you stated in the original case, and as my proposed patch solves.

Should the ctor allow negative coefficients?
With the given algorithm, the proper way to ensure that there are a minimal amount of clashes
is to use two primes. Two relative primes could be also probably be used pretty safely.
The question is how strict do you want to be?
IMHO, disallowing negative coefficients is an arbitrary limitation. (-17, -37) would probably
give better hash codes than (1, 1), or even any combination of the form (a, na) for most classes.
Should those be disallowed too? (and if so - should/could this be done now? It would break
backwards compatibility)
> Redundant check for zero in HashCodeBuilder ctor
> ------------------------------------------------
>                 Key: LANG-804
>                 URL:
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.builder.*
>            Reporter: Sebb
>            Priority: Minor
> The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking
for an odd number.
> Zero is never odd, so the zero check could be eliminated.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message