commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1180231 - /commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
Date Sun, 09 Oct 2011 12:10:50 GMT
On 7 October 2011 21:53,  <simonetripodi@apache.org> wrote:
> Author: simonetripodi
> Date: Fri Oct  7 20:53:25 2011
> New Revision: 1180231
>
> URL: http://svn.apache.org/viewvc?rev=1180231&view=rev
> Log:
> '4' is a magic number.

Agreed.

> Modified:
>    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
>
> Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java?rev=1180231&r1=1180230&r2=1180231&view=diff
> ==============================================================================
> --- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
(original)
> +++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
Fri Oct  7 20:53:25 2011
> @@ -48,6 +48,9 @@ public class UnaryCompositeBinaryFunctio
>      */
>     private static final long serialVersionUID = 264219357293822629L;
>
> +    /** Base hash integer used to shift hash. */
> +    private static final int HASH_SHIFT = 4;
> +

We know what it is used for, but why choose 4 rather than 3 or 42 or 1?

Is it arbitrary? If so, what is the possible range?
If not arbitrary, why choose 4?

>     /**
>      *
>      *
> @@ -157,11 +160,11 @@ public class UnaryCompositeBinaryFunctio
>      */
>     public int hashCode() {
>         int hash = "UnaryCompositeBinaryFunction".hashCode();
> -        hash <<= 4;
> +        hash <<= HASH_SHIFT;
>         hash ^= helper.f.hashCode();
> -        hash <<= 4;
> +        hash <<= HASH_SHIFT;
>         hash ^= helper.g.hashCode();
> -        hash <<= 4;
> +        hash <<= HASH_SHIFT;
>         hash ^= helper.h.hashCode();
>         return hash;
>     }
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message