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:11:02 UTC
svn commit: r550122 - in
/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id:
ModuleId.java ModuleRevisionId.java
Author: gscokart
Date: Sat Jun 23 15:11:01 2007
New Revision: 550122
URL: http://svn.apache.org/viewvc?view=rev&rev=550122
Log:
clean code (lazy calculation of the hashcode)
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.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=550122&r1=550121&r2=550122
==============================================================================
--- 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:11:01 2007
@@ -58,7 +58,7 @@
}
public int hashCode() {
- if (hash==0) {
+ if (hash == 0) {
//CheckStyle:MagicNumber| OFF
hash = 31;
hash = hash * 13 + (organisation == null ? 0 : organisation.hashCode());
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?view=diff&rev=550122&r1=550121&r2=550122
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Sat Jun 23 15:11:01 2007
@@ -81,13 +81,13 @@
this(moduleId, null, revision, extraAttributes);
}
- public ModuleRevisionId(ModuleId moduleId, String branch, String revision, Map extraAttributes) {
+ public ModuleRevisionId(ModuleId moduleId, String branch, String revision,
+ Map extraAttributes) {
super(null, extraAttributes);
this.moduleId = moduleId;
this.branch = branch == null ? IvyContext.getContext().getSettings().getDefaultBranch(
moduleId) : branch;
this.revision = revision == null ? Ivy.getWorkingRevision() : revision;
- hash = _hashCode(); // stored for performance reasons, hashCode is very used in many maps
setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
@@ -122,17 +122,18 @@
}
public int hashCode() {
+ if (hash == 0) {
+ //CheckStyle:MagicNumber| OFF
+ hash = 31;
+ hash = hash * 13 + (getBranch() == null ? 0 : getBranch().hashCode());
+ hash = hash * 13 + getRevision().hashCode();
+ hash = hash * 13 + getModuleId().hashCode();
+ hash = hash * 13 + getAttributes().hashCode();
+ //CheckStyle:MagicNumber| ON
+ }
return hash;
}
- public int _hashCode() {
- int hash = 31;
- hash = hash * 13 + (getBranch() == null ? 0 : getBranch().hashCode());
- hash = hash * 13 + getRevision().hashCode();
- hash = hash * 13 + getModuleId().hashCode();
- hash = hash * 13 + getAttributes().hashCode();
- return hash;
- }
public String toString() {
return "[ " + moduleId.getOrganisation() + " | " + moduleId.getName()