From 9a6561c6f6fa2cf0b9c99008c63765fb8ad3a717 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 20 Jul 2009 18:13:49 +0000 Subject: [PATCH] o Optimized performance (the string concatenation in getId() severely affected ReactorArtifactRepository which in turn is heavily used for key calculation/comparision in the plugin & metadata cache) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@795939 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/project/MavenProject.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 155e608308..a703b8f730 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -1598,18 +1598,27 @@ else if ( !( other instanceof MavenProject ) ) { return false; } - else - { - MavenProject otherProject = (MavenProject) other; - return getId().equals( otherProject.getId() ); - } + MavenProject that = (MavenProject) other; + + return eq( getArtifactId(), that.getArtifactId() ) + && eq( getGroupId(), that.getGroupId() ) + && eq( getVersion(), that.getVersion() ); + } + + private static boolean eq( T s1, T s2 ) + { + return ( s1 != null ) ? s1.equals( s2 ) : s2 == null; } @Override public int hashCode() { - return getId().hashCode(); + int hash = 17; + hash = 31 * hash + getGroupId().hashCode(); + hash = 31 * hash + getArtifactId().hashCode(); + hash = 31 * hash + getVersion().hashCode(); + return hash; } public List getBuildExtensions()