You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by gs...@apache.org on 2007/06/23 22:07:46 UTC

svn commit: r550121 - /incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java

Author: gscokart
Date: Sat Jun 23 15:07:46 2007
New Revision: 550121

URL: http://svn.apache.org/viewvc?view=rev&rev=550121
Log:
clean code (lazy calculation of the hashcode)

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java?view=diff&rev=550121&r1=550120&r2=550121
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java Sat Jun 23 15:07:46 2007
@@ -35,7 +35,6 @@
         }
         this.organisation = organisation;
         this.name = name;
-        hash = _hashCode(); // stored for performance reasons, hashCode is very used in many maps
     }
 
     public String getName() {
@@ -59,17 +58,16 @@
     }
 
     public int hashCode() {
+        if (hash==0) {
+            //CheckStyle:MagicNumber| OFF
+            hash = 31;
+            hash = hash * 13 + (organisation == null ? 0 : organisation.hashCode());
+            hash = hash * 13 + name.hashCode();
+            //CheckStyle:MagicNumber| ON
+        }
         return hash;
     }
 
-    public int _hashCode() {
-        //CheckStyle:MagicNumber| OFF
-        int hash = 31;
-        hash = hash * 13 + (organisation == null ? 0 : organisation.hashCode());
-        hash = hash * 13 + name.hashCode();
-        //CheckStyle:MagicNumber| ON
-        return hash;
-    }
 
     public String toString() {
         return "[ " + organisation + " | " + name + " ]";